bon_sandbox/
attr_default.rs1#[derive(bon::Builder)]
2#[builder(builder_type(
3 doc {
4 },
7))]
8#[allow(
9 clippy::struct_field_names,
10 reason = "Common `_default` suffix is for better readability"
11)]
12pub struct Example {
13 #[builder(default = (2 + 2) * 10)]
16 small_custom_default: u32,
17
18 #[builder(default = Vec::from([
21 Point { x: 1, y: 2 },
22 Point { x: 3, y: 4 },
23 Point { x: 5, y: 6 },
24 Point { x: 7, y: 8 },
25 ]))]
26 big_custom_default: Vec<Point>,
27
28 #[builder(default)]
29 standard_u32_default: u32,
30
31 #[builder(default)]
32 standard_string_default: String,
33}
34
35pub struct Point {
36 x: u32,
37 y: u32,
38}