[−][src]Derive Macro unprolix::Constructor
#[derive(Constructor)] { // Attributes available to this derive: #[unprolix] }
Generate a pub fn new(...) -> Self
method
All the attributes will be included as parameters of the new
function.
Default
Some attributes who implements Default
may not be required as parameter of the constructor.
For that, there is the option to use #[unprolix(default)]
Expansion
The following code
ⓘThis example is not tested
#[derive(Constructor)] struct SomeStruct { a: u8, b: u8, #[unprolix(default)] c: u8, }
Expands to
ⓘThis example is not tested
impl SomeStruct { pub fn new(a, b) -> Self { Self { a, b, c: Default::default(), } } }