custom_default

Crates.iocustom_default
lib.rscustom_default
version0.0.2
sourcesrc
created_at2019-01-27 01:51:52.437475
updated_at2019-01-28 18:32:13.222087
descriptiongenerate custom default values for struct fields
homepage
repositoryhttps://github.com/slmjkdbtl/custom_default/
max_upload_size
id110850
size5,056
tga (slmjkdbtl)

documentation

README

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,
});
Commit count: 0

cargo fmt