1 #![deny(clippy::all, clippy::pedantic)]
2
3 use std::io;
4 use thiserror::Error;
5
6 #[derive(Error, Debug)]
7 #[error("...")]
8 pub struct ErrorStruct {
9 #[from]
10 source: io::Error,
11 }
12
13 #[derive(Error, Debug)]
14 #[error("...")]
15 pub struct ErrorTuple(#[from] io::Error);
16
17 #[derive(Error, Debug)]
18 #[error("...")]
19 pub enum ErrorEnum {
20 Test {
21 #[from]
22 source: io::Error,
23 },
24 }
25
26 #[derive(Error, Debug)]
27 #[error("...")]
28 pub enum Many {
29 Any(#[from] anyhow::Error),
30 Io(#[from] io::Error),
31 }
32
assert_impl<T: From<io::Error>>()33 fn assert_impl<T: From<io::Error>>() {}
34
35 #[test]
test_from()36 fn test_from() {
37 assert_impl::<ErrorStruct>();
38 assert_impl::<ErrorTuple>();
39 assert_impl::<ErrorEnum>();
40 assert_impl::<Many>();
41 }
42