1 unstable release
0.1.0 | Oct 27, 2024 |
---|
#629 in Development tools
9KB
builder!
A macro, or two, to simplify usage of builder pattern on structs.
use builder_option::Builder;
#[derive(Debug, Builder)]
pub struct Client {
pub field: bool,
pub another: Option<bool>,
pub optional: Option<String>,
}
fn main() -> Result<(), dyn std::error::Error> {
let client = Client::builder()
.with_field(true)
.with_another(false),
.build()?;
assert!(client.field);
assert_eq!(client.another, false);
assert!(client.optional.is_none());
}
LICENSE
Dependencies
~95KB