3 use std::boxed::ThinBox;
9 let expected = "Foo error!";
10 let mut dropped = false;
12 let foo = Foo(expected, &mut dropped);
13 let a: ThinBox<dyn Error> = ThinBox::new_unsize(foo);
15 let msg = a.to_string();
16 assert_eq!(expected, msg);
23 struct Foo<'a>(&'static str, &'a mut bool);
25 impl Drop for Foo<'_> {
31 impl fmt::Display for Foo<'_> {
32 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
33 write!(f, "{}", self.0)
37 impl Error for Foo<'_> {}