| Crates.io | derive_aliases |
| lib.rs | derive_aliases |
| version | 0.2.2 |
| created_at | 2025-09-15 00:27:57.295848+00 |
| updated_at | 2025-09-15 05:07:59.76512+00 |
| description | `#[derive]` aliases for reducing code boilerplate |
| homepage | |
| repository | https://github.com/nik-rev/derive-aliases |
| max_upload_size | |
| id | 1839290 |
| size | 36,699 |
derive_aliasesThis crate provides #[derive] aliases for reducing code boilerplate.
Copy = Copy, Clone#[derive(Debug, ..Copy)] expands to #[std::derive(Debug, Copy, Clone)]Aliases are defined in a special file derive_aliases.rs, located next to your crate's Cargo.toml:
// Simple derive aliases
//
// `#[derive(..Copy, ..Eq)]` expands to `#[std::derive(Copy, Clone, PartialEq, Eq)]`
Copy = Copy, Clone;
Eq = PartialEq, Eq;
// You can nest them!
//
// `#[derive(..Ord, std::hash::Hash)]` expands to `#[std::derive(PartialOrd, Ord, PartialEq, Eq, std::hash::Hash)]`
Ord = PartialOrd, Ord, ..Eq;
This file uses a tiny domain-specific language for defining the derive aliases (the parser is less than 20 lines of code!). .rs is used just for syntax highlighting.
These aliases can then be used in Rust like so:
// This globally overrides `std::derive` with `derive_aliases::derive` across the whole crate! Handy.
#[macro_use]
extern crate derive_aliases;
#[derive(..Copy, ..Ord, std::hash::Hash)]
struct HelloWorld;
This expands to:
#[derive(Copy, Clone, PartialOrd, Ord, PartialEq, Eq, std::hash::Hash)]
struct HelloWorld;
With Ord alias defines as follows:
Eq = PartialEq, Eq;
Ord = PartialOrd, Ord, ..Eq;
Hovering over ..Ord will show that it expands to PartialOrd, Ord, PartialEq, Eq:

derive_aliases.rs in Cargo WorkspacesIf you want to use the same derive_aliases.rs for all crates in your Cargo workspace, enable the workspace feature then define the CARGO_WORKSPACE_DIR env variable in .cargo/config.toml:
[env]
CARGO_WORKSPACE_DIR = { value = "", relative = true }
use other alias files in derive_aliases.rsuse followed by a path will inline the derive aliases located in that file.
If ../my_other_aliases.rs contains:
Ord = PartialOrd, Ord, ..Eq;
And your derive_aliases.rs has:
use "../my_other_aliases.rs";
Eq = PartialEq, Eq;
Then it will inline the aliases in the other file, expanding to:
Ord = PartialOrd, Ord, ..Eq;
Eq = PartialEq, Eq;
1.80