use relax::Relax; #[derive(Relax, Debug, PartialEq)] #[relax(PartialFoo)] pub struct Foo { #[relax] pub bar_1: Bar, #[relax] pub bar_2: Option, } #[derive(Relax, Debug, PartialEq)] #[relax(PartialBar)] pub struct Bar { pub id: u16, } #[test] fn nest() { let partial_bar = PartialBar { id: Some(42) }; let partial_foo = PartialFoo { bar_1: Some(partial_bar), bar_2: None, }; let foo: Foo = partial_foo.try_into().unwrap(); let expected_foo = Foo { bar_1: Bar { id: 42 }, bar_2: None, }; assert_eq!(foo, expected_foo); }