derive_aliases
This crate improves Rust's derive macro by supporting user-defined Derive aliases.
[]
= "0.3"
Usage
Define aliases using define!, and use them with #[derive]:
use derive;
// Use the aliases:
;
The above expands to this:
;
#[derive(..Eq)]expands to#[derive(::core::cmp::PartialEq, ::core::cmp::Eq)]#[derive(..Ord)]expands to#[derive(..Eq, ::core::cmp::PartialOrd, ::core::cmp::Ord)], which expands to#[derive(::core::cmp::PartialEq, ::core::cmp::Eq, ::core::cmp::PartialOrd, ::core::cmp::Ord)]
IDE Support
Hovering over an alias #[derive(..Alias)] shows exactly what it expands into, and even Goto Definition directly brings you where the alias is defined.

Tip
To globally override #[std::derive] with #[derive_aliases::derive], add the following:
extern crate derive_aliases;
The above lets you define! aliases and then use them anywhere in your crate!
I have put a ton of effort into optimizing derive_aliases to be as zero-cost as possible in terms of compile-time over the standard library's derive,
so don't worry about any overhead of #[derive_aliases::derive] even when no aliases are used! derive_aliases has 0 dependencies (not even quote or syn!)
Derives are de-duplicated
Each derive alias expands into a bunch of derives, then de-duplicated. If there are 2 or more of the same derive, only 1 is kept. This is useful when there are some "pre-requisite" derives needed, but if they already exist then don't add them (instead of compile error'ing).
extern crate zerocopy;
;
// expands to:
;
;
// expands to:
;
;
// expands to:
;
// note that the 2 `Immutable` and 2 `IntoBytes` derives were de-duplicated
Splitting up derive aliases
All derive aliases must exist at your crate::derive_alias, so invoke the derive_aliases::define! macro there.
You can break define! apart into multiple definitions:
;
The above Just Works. Most importantly, derive aliases need to available at crate::derive_alias. This also allows you to share derive aliases across crates