derive_more
Adds #[derive(...)] macros for Add, From, Display, IntoIterator, Deref, and other common Rust traits
Repository Health
Technical Analysis
Rust’s built-in operator and conversion traits (Add, From, Display, IntoIterator, Deref, and dozens more) are implemented for primitive types, but wrapping a primitive in a newtype struct (e.g. struct MyInt(i32)) loses all of them, forcing hand-written boilerplate for each trait you want back. derive_more supplies #[derive(...)] macros that regenerate these trait implementations automatically for structs and enums, so simple wrapper types stay simple.
The crate is organized by feature flag per derivable trait group (conversion traits like From/TryFrom/IntoIterator; formatting traits like Display/Debug; operator traits like Add/Mul/Not; and static-method derives like Constructor/IsVariant/Unwrap), so consumers only compile the macros they actually use rather than pulling in the whole set by default.
What You Get
- Per-trait derive macros (
#[derive(From, Add, Display)], etc.) covering conversion, formatting, operator, and equality traits - Feature-flagged compilation — enable only the specific derives you use (
features = ["from", "add"]) to keep build times down, or"full"for everything - Enum support for most derives, including per-variant
#[display("...")]format strings and generatedis_foo()/unwrap_foo()static methods viaIsVariant/Unwrap - A
no_std-compatible mode (disable default features) for embedded or allocation-free crates - Re-exports of the underlying standard-library traits alongside the derive macros via the
with_traitmodule, avoiding naming collisions when only the macro is wanted
Common Use Cases
- Implementing the newtype pattern (e.g. wrapping a
u64for a strongly-typed ID) without hand-writingFrom/Display/Addboilerplate - Deriving
Displaywith custom per-variant format strings for enum-based error or domain types - Adding arithmetic operator support (
Add,Mul, etc.) to simple numeric wrapper structs used in scientific or domain-modeling code - Generating
is_variant()/unwrap_variant()helper methods on enums to reduce manual pattern-matching boilerplate
Under The Hood
Architecture: The crate is split between src/ (the public-facing macro definitions and re-exports, e.g. add.rs, fmt.rs, convert.rs, cmp.rs, ops.rs, str.rs, try_unwrap.rs) and a separate impl/ crate containing the actual proc-macro implementation logic that parses derive input and generates trait impl code. This two-crate split (a thin public macro crate plus a private -impl crate) is a common Rust pattern for proc-macro libraries, letting the impl crate depend on syn/quote while the public crate stays lean. Each derivable trait or trait-family (Add-like, Mul-like, AddAssign-like) is implemented as its own module, generating code specific to that trait’s semantics (e.g. operator traits need per-field composition logic that formatting traits don’t).
Tech Stack: Pure Rust, edition = 2021, rust-version = 1.81.0, structured as a two-crate workspace (derive_more + derive_more-impl) plus a build.rs for compile-time feature detection. The crate explicitly forbids unsafe code (badge: ‘Unsafe Forbidden’). Categories in Cargo.toml (development-tools::procedural-macro-helpers, no-std, rust-patterns) reflect its positioning as boilerplate-reduction tooling.
Code Quality: A tests/ directory with 32+ top-level test files exercises each derivable trait independently (matching the per-trait module split in src/), and CI configuration lives under ci/. With 76 contributors and a MSRV policy documented explicitly as a semver-relevant minor-version bump (unusually precise versioning discipline for a macro crate), the project shows mature, deliberate maintenance despite a moderate day-to-day commit cadence.
API Design: The #[derive(Add, Display, From)] syntax mirrors how developers already derive Debug/Clone, so there’s essentially zero new API surface to learn — each additional trait is just another name in the derive list, and the crate documents exactly what code each derive expands to (recommending cargo-expand to inspect it), which is unusually transparent for a proc-macro library.
Used by 4 apps in this directory
Hook0
Devops
Open-source Webhooks-as-a-Service: deliver events to your users with auto-retry, signed payloads, and a real-time subscriber dashboard — all without building the infrastructure yourself.
Qdrant
Databases · AI Development · Search
Open-source vector database and search engine built in Rust for production-grade AI applications — from semantic search to RAG pipelines and recommendation systems.
Trieve
AI Development · Search · Developer Tools
All-in-one self-hostable platform for hybrid search, RAG, recommendations, and analytics built on Rust and Qdrant.
Vaultwarden
Password Manager · Security
Unofficial Bitwarden-compatible server in Rust — run the full Bitwarden ecosystem on a Raspberry Pi using every official client you already have, without the multi-container overhead.