Crate staged_builder
source ·Expand description
A procedural macro which creates a “staged” builder for a type.
Staged (also known as telescopic) builders are a style of infallible builders; code will not compile if any required
fields are not set. Specifically, the builder advances in order through a sequence of “stage” types, each
corresponding to a required field of the struct. The final stage has setters for all optional fields and the final
.build()
method.
See the documentation for #[staged_builder]
for more details.
§Examples
use staged_builder::staged_builder;
#[staged_builder]
struct Person {
#[builder(into)]
name: String,
age: u32,
#[builder(list(item(type = Person)))]
parents: Vec<Person>,
}
let person = Person::builder()
.name("John Doe")
.age(25)
.build();
Modules§
- Builder types for
ExamplePerson
.
Structs§
- An example type using
#[staged_builder]
.
Traits§
- A trait for types which validate their state before construction finishes.
Attribute Macros§
- Creates a staged builder interface for structs.