Last Updated: November 21, 2025
Macro Types
| Type | When |
|---|---|
macro_rules!
|
Pattern matching |
Custom derive
|
Generate impls |
Attribute
|
Annotate items |
Commands
cargo expand
See expansion
#[derive(Custom)]
Invoke custom derive
proc-macro crate
Implement logic
Guidance
Keep macros ergonomic, document inputs, and avoid confusing syntax.
💡 Pro Tip:
Start with macro_rules! before procedural macros when possible.