builders 0.5.0

Rust macros for building structs
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use builders::*;

#[derive(Builder,Getters,Setters)]
pub struct Command<'a,T: Clone> {
    #[builder(vec = "arg")]
    args: Vec<&'a str>,
    i: T,
}

fn main() {
    let command: Command<'_,i32> = Command::builder()
        .arg("build")
        .i(12)
        .build()
        .unwrap();
    assert_eq!(command.get_args(), &["build"]);
    assert_eq!(*command.get_i(), 12);
}