Rust has support for several forms of metaprogramming, which means writing programs that write programs. It can be a very powerful technique that helps surpass limitations of the language itself. It's a rather challenging way to program, however, and requires much more care and consideration than writing regular functions.
The oldest and most stable form of metaprogramming in Rust is syntactic macros. We'll cover those in this chapter.
This chapter will cover the following topics:
- Introduction to metaprogramming
- Dissecting println!
- Macro keywords
- Repeating constructs
- Building our own macros