X-Macro: How to avoid repetition
summary
Shows an implemented pattern that keeps one single source list of enum entries and uses the preprocessor to generate both the enum and string conversion so you never forget to update a switch case The demo builds an X‑macro list, redefines X to emit enum values then redefines X again to emit switch case returns Adding a new state updates both places automatically and the approach plainly works for the presented examples
AI-written summary · about
chapters (6)
related talks
39mRust metaprogramming - macro_rules! beyond basics
29mMacromancy: an introduction to Rust macros
24mMacros for a More Productive Rust
29mProcedural Macros vs Sliced Bread
26mMaking life easier with Derive and other tools
18mImpractical Macros
28mA gentle introduction to procedural macros
39mReflection without Reflection TS
