use std::error::Error as StdError;
use std::io;
use wherror::Error;
#[derive(Error, Debug)]
pub enum TestEnumFromBox {
#[error("io error")]
Io {
#[from]
source: Box<io::Error>,
},
#[error("other error")]
Other,
}
#[test]
fn test_enum_box_from() {
let io_error = io::Error::new(io::ErrorKind::Other, "test error");
let boxed_error = Box::new(io_error);
let error = TestEnumFromBox::from(boxed_error);
println!("Created enum error from Box: {error:?}");
}
#[test]
fn test_enum_unboxed_from() {
let io_error = io::Error::new(io::ErrorKind::Other, "test error");
let error = TestEnumFromBox::from(io_error); println!("Created enum error from unboxed: {error:?}");
assert!(error.source().is_some());
}