use typed_builder::TypedBuilder;
#[derive(PartialEq, TypedBuilder)]
struct Foo {
x: i32,
#[builder(default, setter(strip_option))]
y: Option<i32>,
#[builder(default = 20)]
z: i32,
}
fn main() {
assert!(
Foo::builder().x(1).y(2).z(3).build()
== Foo {
x: 1,
y: Some(2),
z: 3,
}
);
assert!(
Foo::builder().z(1).x(2).y(3).build()
== Foo {
x: 2,
y: Some(3),
z: 1,
}
);
assert!(
Foo::builder().x(1).build()
== Foo {
x: 1,
y: None,
z: 20,
}
);
}