0.0.2 |
|
---|---|
0.0.1 |
|
0.0.0 |
|
#57 in #default-value
4KB
64 lines
custom_default
generate custom default values for struct fields
example
use custom_default::CustomDefault;
#[derive(CustomDefault, Debug)]
struct Person {
#[default("Jack")]
name: &'static str,
#[default(12)]
age: u32,
#[default(true)]
dead: bool,
// without the `default` attr it will work like normal `#[derive(Default)]`
size: usize,
}
assert!(Person::default() == Person {
name: "Jack",
age: 12,
dead: true,
size: 0,
});
Dependencies
~2MB
~47K SLoC