blob: e1ddade84af75306a0ec2cd1390ea1bdf0a9172e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#[macro_use]
extern crate pretty_assertions;
#[macro_use]
extern crate derive_builder;
#[derive(Debug, PartialEq, Default, Builder, Clone)]
#[builder(setter(prefix = "with"))]
struct Lorem {
ipsum: &'static str,
#[builder(setter(name = "foo"))]
pub dolor: &'static str,
}
#[test]
fn renamed_setter() {
let x = LoremBuilder::default()
.with_ipsum("ipsum")
.foo("dolor")
.build()
.unwrap();
assert_eq!(
x,
Lorem {
ipsum: "ipsum",
dolor: "dolor",
}
);
}
|