macro_rules! erecto {
($t:ty) => { ... };
($t:ty: $($arg:expr),*) => { ... };
}
Expand description
Constructs the given type using either the Default::default
or new(<optional args>)
functions.
Calling it with erecto!(type)
results in the former, while
erecto!(type: <optional args>)
results in the latter.
ยงExamples
#[derive(Debug, Default, PartialEq)]
struct Thing {
x: u8,
}
impl Thing {
fn new(x: u8) -> Self {
Self { x }
}
}
assert_eq!(erecto!(u8), 0);
assert_eq!(erecto!(String), String::default());
assert_eq!(erecto!(String:), String::new());
assert_eq!(erecto!(Thing), Thing::default());
assert_eq!(erecto!(Thing: 5), Thing::new(5));