Derive Macro appy_macros::ComponentBuilder

source ·
#[derive(ComponentBuilder)]
Expand description

Create builder.

Create a builder implementation. For example, when placed on the following struct:

struct MyStruct {
    an_int:i32,
    an_optional_string:Option<String>
}

This macro will create the following implementation:

impl MyStruct {
    pub fn new()->ElementWrap<Self> {
        // ...
    }

    pub fn an_int(ElementWrap<Self>,v:i32)->ElementWrap<Self> {
        // ...
    }

    pub fn an_optional_string(ElementWrap<Self>,v:String)->ElementWrap<Self> {
        // ...
    }
}

Notes:

  • For optional properties, e.g. fields wrapped in Option<...>, the setter in the builder will take the wrapped type as parameter and call Some() with the value.