diff options
Diffstat (limited to 'vendor/derive_builder/tests/setter_into.rs')
-rw-r--r-- | vendor/derive_builder/tests/setter_into.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/vendor/derive_builder/tests/setter_into.rs b/vendor/derive_builder/tests/setter_into.rs new file mode 100644 index 000000000..b73852d88 --- /dev/null +++ b/vendor/derive_builder/tests/setter_into.rs @@ -0,0 +1,35 @@ +#[macro_use] +extern crate pretty_assertions; +#[macro_use] +extern crate derive_builder; + +#[derive(Debug, PartialEq, Default, Builder, Clone)] +struct Lorem { + #[builder(setter(into))] + foo: String, +} + +#[derive(Debug, PartialEq, Default, Builder, Clone)] +#[builder(setter(into))] +struct Ipsum { + foo: u32, +} + +#[test] +fn generic_field() { + let x = LoremBuilder::default().foo("foo").build().unwrap(); + + assert_eq!( + x, + Lorem { + foo: "foo".to_string() + } + ); +} + +#[test] +fn generic_struct() { + let x = IpsumBuilder::default().foo(42u8).build().unwrap(); + + assert_eq!(x, Ipsum { foo: 42u32 }); +} |