October 2019
Intermediate to advanced
444 pages
10h 37m
English
As appropriate, we use a macro—macro_rules!—to create a custom macro as we did in step 3. A single macro matches a pattern and consists of three parts:
Calling a macro is always done using its name followed by an exclamation mark (step 4), and for specific patterns, with the required characters/words (step 6). Note that plus and others are not variables, types, or otherwise defined—which gives you the power to create your own domain-specific language (DSL)! More on that in other recipes in this chapter.
By calling a macro, the compiler takes note of the position in the abstract syntax tree (AST) and, instead ...
Read now
Unlock full access