Expand description
Something which can create a default object of some type.
The only required function in this trait is
build
which creates an object, consuming the
builder. Most builders will allow customisation of the produced
object in some way.
An object implementing this trait will be automatically created
for you as part of the Buildable
derive macro. That
builder will have a method for each field of the result type, to
customise its value, and will produce a default value for every
field which is not customised.
Required Associated Types
Required Methods
Create the final object.
Example
use boulder::Builder;
struct Foo {
a: i32
}
struct FooBuilder {
a: i32
}
impl Builder for FooBuilder {
type Result = Foo;
fn build(self) -> Self::Result {
Foo { a: self.a }
}
}
let b = FooBuilder { a: 3 };
let f = b.build();
assert_eq!(f.a, 3);