macro_rules! meta_default_constructor { ( {$($imports: stmt);* $(;)?} $($tt: tt)* ) => { ... }; ( [$func: expr] $ty: ident $([$($generics: tt)*])? {$($tt: tt)*} ) => { ... }; ( [$func: expr] $ty: ident $([$($generics: tt)*])? {$field: ident: $ty2: ident {$($fields: tt)*} $(, $($tt: tt)*)?} {$($out_field: ident: $out_expr: expr),*} ) => { ... }; ( [$func: expr] $ty: ident $([$($generics: tt)*])? {$field: ident: box $ty2: ident {$($fields: tt)*} $(, $($tt: tt)*)?} {$($out_field: ident: $out_expr: expr),*} ) => { ... }; ( [$func: expr] $ty: ident $([$($generics: tt)*])? {$field: ident: $expr: expr $(, $($tt: tt)*)?} {$($out_field: ident: $out_expr: expr),*} ) => { ... }; ( [$func: expr] $ty: ident $([$($generics: tt)*])? {} {$($field: ident: $expr: expr),*} ) => { ... }; }
Expand description
The meta macro.
§Syntax
meta_default_constructor!(
// scoped imports, optional, must be in braces `{..}`
{
import std::future::Future;
import rand::prelude::*;
}
// conversion function, required
[Into::into]
// struct name, required
MyStruct
// generics, optional, must be in brackets `[..]`
// this is equivalent to specifying `::<f32, String>`
[f32, String]
// fields
{
// name value pairs like normal
name: value,
// value is converted via the conversion function
name: value,
// OtherStruct will be constructed using `meta_default_constructor!`
// use another syntax like wrapping it in parenthesis to ignore this
name: OtherStruct {
..
},
// append [..Default::default()] at the end
}
)