is_default-1.0.0 has been yanked.
A unified API for checking if a value is default, with easy derive support for custom types.
Example, instead of is_none
for Option
and is_empty
for Vec
can be used is_default
for all.
assert!;
assert!;
use IsDefault;
assert!;
assert!;
The IsDefault
trait is implemented for most standard types.
With the derive
feature, you can easily generate implementations for
your own types:
Derive
To use derive macro add dependency with the feature derive
in
Cargo.toml:
is_default = { version = "1", features = ["derive"] }
Structs
A struct can derive IsDefault
if all its fields implement IsDefault
.
use IsDefault;
;
assert!;
;
assert!;
assert!;
assert!;
assert!;
assert!;
Enums
Enums can derive IsDefault
using the #[is_default]
or #[default]
attribute. This allows deriving both Default
and IsDefault
using
the same attribute.
use IsDefault;
assert!;
assert!;
assert!;
assert!;
assert!;
assert!;
assert!;