In this chapter, we covered many of the advanced macro features of Rust. They allow a Rust programmer to run arbitrary Rust code at compile time for various effects:
- To generate Rust code based on some outside environmental state (such as database tables, time of date, and so on)
- To decorate structures with custom attributes, generating arbitrary code for them at compile time
- To create new linter plugins for making additional code checking passes that Rust itself does not support
Many of these features require the nightly version of the Rust compiler. There's a workaround via a code generation library called syntex, which enables many uses of nightly macros to work on the stable compiler, but it is slightly awkward to use.
The Rust ...