use fromsuper::FromSuper; use ::anyhow; struct Bar { x: Option>, } #[derive(FromSuper)] #[fromsuper(from_type = "Bar", unpack = true)] struct Foo { #[allow(dead_code)] x: Vec, } fn anyhow_convert_inner_1() -> anyhow::Result { let foo = Foo::try_from(Bar { x: Some(vec![42]) })?; Ok(foo) } fn anyhow_convert_inner_2() -> anyhow::Result { let foo = Foo::try_from(Bar { x: None })?; Ok(foo) } #[test] fn anyhow_convert() { assert!(anyhow_convert_inner_1().is_ok()); assert!(anyhow_convert_inner_2().is_err()); }