auto-default
This crate provides an attribute macro #[auto_default], which adds a default field value of
Default::default() to fields that do not have one.
[]
= "0.1"
Note: auto-default has zero dependencies. Not even syn! The compile times are very fast.
Showcase
Rust's default field values allow
the shorthand Struct { field, .. } instead of the lengthy Struct { field, ..Default::default() }
For .. instead of ..Default::default() to work,
your Struct needs all fields to have a default value.
This often means = Default::default() boilerplate on every field, because it is
very common to want field defaults to be the value of their Default implementation
Before
With #[auto_default]
You can apply the #[auto_default] macro to structs with named fields, or enums
If any field or variant has the #[auto_default(skip)] attribute, a default field value of Default::default()
will not be added