Derive Macro optargs::OptStruct[][src]

#[derive(OptStruct)]
{
    // Attributes available to this derive:
    #[builder]
}

Flexible struct builder with optional arguments Derive OptStruct for your structs and then call the Struct’s name as a macro to build it, eliding optionals.

Note that this still obeys traditional macro_rules, so you can only use the macro after declaration or import it from “crate”.

#[derive(optargs::OptStruct)]
pub struct Scatter {
    x: Vec<i32>,
    y: Option<Vec<i32>>,
    title: Option<&str>,
    xlabel: Option<&str>,
    ylabel: Option<&str>,
    legend: Option<bool>
}

let plot = Scatter!{
    x: vec![1,2,3],
    legend: true
};