#[derive(BuilderLite)]
{
// Attributes available to this derive:
#[builder_lite]
}
Expand description
Automatically implement the Builder Lite pattern for a struct.
This will create an impl
which contains methods for each field of a
struct, allowing users to easily set the values. The generated methods will
be the field name prefixed with with_
, and calls to these methods can be
chained as needed.
ยงExample
#[derive(Default)]
enum MyEnum {
#[default]
A,
B,
}
#[derive(Default, BuilderLite)]
#[non_exhaustive]
struct MyStruct {
enum_field: MyEnum,
bool_field: bool,
option_field: Option<i32>,
}
MyStruct::default()
.with_enum_field(MyEnum::B)
.with_bool_field(true)
.with_option_field(-5);