.. | ||
styles | ||
Clone.md | ||
cmp.md | ||
custom.css | ||
debug-transparent-orig.rs | ||
debug-transparent.rs | ||
Debug.md | ||
default-enum-orig.rs | ||
default-enum.rs | ||
default-value-orig.rs | ||
default-value.rs | ||
Default.md | ||
eq-ignore-orig.rs | ||
eq-ignore.rs | ||
Hash.md | ||
README.md | ||
SUMMARY.md |
Derivative
This crate provides a set of alternative #[derive]
attributes for Rust.
Examples
derivative uses attributes to make it possible to derive more implementations
than the built-in derive(Trait)
. Here are a few examples of stuffs you cannot
just derive
.
You can derive Default
on enumerations:
With derivative |
|
---|---|
{{#playground default-enum.rs}} |
{{#playground default-enum-orig.rs}} |
You can use different default values for some fields:
With derivative |
|
---|---|
{{#playground default-value.rs}} |
{{#playground default-value-orig.rs}} |
Want a transparent Debug
implementation for your wrapper? We got that:
With derivative |
|
---|---|
{{#playground debug-transparent.rs}} |
{{#playground debug-transparent-orig.rs}} |
Need to ignore a field? We got that too:
With derivative |
|
---|---|
{{#playground eq-ignore.rs}} |
{{#playground eq-ignore-orig.rs}} |