Macros and Metaprogramming
Last updated
What is Macros and Metaprogramming?
Macros are code that writes code, enabling metaprogramming in Rust. Declarative macros use macro_rules! for pattern-based code generation, while procedural macros provide custom derives and function-like macros. They're expanded at compile time, offering zero-cost abstractions.
Free resources to learn Macros and Metaprogramming
- Official docsMacros
- Official docsmacro_rules!
- ArticleMacros in Rust: A Tutorial with Examples
- ArticleMetaprogramming Magic in Rust: The Complete Guide
More in stage 9: Macros & Metaprogramming
Macros and Metaprogramming: common questions
Can I learn Macros and Metaprogramming in Hindi?
This lesson is written in English. Once you sign in, open it in the interactive course and ask the AI tutor to explain Macros and Metaprogramming in Hindi or Hinglish. The tutor answers from this lesson’s own text, so it stays on the syllabus, and it runs on your own Google, OpenAI or Anthropic key.
Is this Macros and Metaprogramming tutorial for beginners?
It is lesson 61 of 122 in the free Rust roadmap, in stage 9, Macros & Metaprogramming. If you are new to Rust, start from stage 1 and come back here in order; if you already know the earlier stages, this lesson stands on its own.