1 stable release
1.0.0 | Aug 13, 2024 |
---|
#8 in #uninitialized
Used in orx-pseudo-default
6KB
73 lines
orx-pseudo-default-derive
Derives the PseudoDefault
trait that allows to create a cheap default instance of a type, which does not claim to be useful.
Example
use orx_pseudo_default::PseudoDefault;
use orx_pseudo_default_derive::PseudoDefault;
#[derive(PseudoDefault)]
struct ChildStruct {
a: String,
b: char,
c: Vec<u32>,
}
#[derive(PseudoDefault)]
struct MyStruct {
x: ChildStruct,
y: bool,
z: Option<usize>,
}
assert_eq!(String::pseudo_default(), MyStruct::pseudo_default().x.a);
assert_eq!(char::pseudo_default(), MyStruct::pseudo_default().x.b);
assert_eq!(Vec::<u32>::pseudo_default(), MyStruct::pseudo_default().x.c);
assert_eq!(bool::pseudo_default(), MyStruct::pseudo_default().y);
assert_eq!(
Option::<usize>::pseudo_default(),
MyStruct::pseudo_default().z
);
Dependencies
~220–660KB
~16K SLoC