Macros
The public macros fall into five families. The distinction is about what each macro is allowed to assume about its input, not about which procedural-macro kind happens to implement it.
Structured local syntax
These macros parse a known local shape and generate ordinary Rust:
callableandmake_fn!give objects function-like macro syntax while retaining their original types and methods;discriminated_strcreates a unique string mapping and a literal-selected constructor macro;enum_fnturns per-variant expressions into a method;strutuct!, also exported asemmun!, generates related structs, enums, and constructor macros;overload_oprepeats one operator written for references across its owned operand forms and its augmented assignment;complete_opsadds the operators that follow from the ones a type already has, such as subtraction from addition and negation.
Ordinary Rust fragments and names
These conveniences accept one ordinary Rust fragment or name:
qf!recursively qualifies common paths in one Rust type;stringify_as!converts one identifier or string literal to a selected conventional case, or emits the compact, structure-preserving string name of one Rust type.
Recursive whole-stream extensions
These macros rewrite arbitrary token trees recursively without assuming that the complete input is an item or expression:
shared_match_arms!duplicates one match-arm RHS across independently typed patterns;literally_literal_string!recognizes the deliberately invalid@@"text".
Read How token rewriting behaves before combining the whole-stream extensions with attributes or macros that consume private syntax.
Composition helpers
These helpers transport or protect token streams for another macro:
forward_attributesmoves an item-position macro invocation’s outer attributes behind a;boundary in its opaque input;excluded_macrosmarks macro invocations whose contents a recursive transformation must leave opaque;expand!loads one out-of-line module and wraps its body in one or more whole-stream transformations before rustc parses it.
Meta-transformers
These macros transform macro and token-stream structure itself: