Before we build more complex macros, it's important to become familiar with the valid inputs that macro_rules!
can take. Since macro_rules!
work at the syntactic level, it needs to provide users, a handle to these syntactic elements, and distinguish what can and cannot be included within a macro and how we can interact with them.
The following are some important token tree types that you can pass into a macro as input:
block
: This is a sequence of statements. We have already usedblock
in the debugging example. It matches any sequence of statements, delimited by braces, such as what we were using before:
{ silly; things; }
This block includes the statements silly
and things
.