use buildstructor::buildstructor; pub struct Foo { simple: usize, } #[buildstructor] impl Foo { #[builder] fn new(simple: usize) -> Result { Ok(Self { simple }) } #[builder] fn self_new(simple: usize) -> Result { Ok(Self { simple }) } #[builder] fn deep_self_new(simple: usize) -> Result, String> { Ok(Ok(Self { simple })) } } fn main() { let _ = Foo::builder().simple(2).build().is_ok(); let _ = Foo::self_builder().simple(2).build().is_ok(); let _ = Foo::deep_self_builder().simple(2).build().is_ok(); }