better_default 1.0.5

The std Default derive, but it allows to constomize the default fields values and has some upgrades.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#![allow(dead_code)]

use better_default::Default;

#[derive(Default, Debug)]
// Top default attributes are optional for structs.
struct Struct {
    #[default(10)] // set the default value of field1 to be 10
    field1: u32,

    field2: String,
}

fn main() {
    let default = Struct::default();
    println!("{:?}", default) // should print "Struct { field1: 10, field2: "" }"
}