This crate provides a set of alternative #[derive]
attributes for Rust.
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}}