Because writing books about Rust is the kewl thing to do these days (and because I don’t have the personality or ethic for a blog), it’s a big brain-dump of a fair part of what I know about writing macros in Rust.
This is intended to be kind of like the Rustonomicon, but for macros: it goes through how they work, the gotchas, the weird minutiae, and contains various patterns and examples.
It is not finished, in the sense that a major part of it is meant to collect patterns, building blocks, and annotated examples. The two introductions (one methodical, one practical) should be more or less done. If you feel anything is missing from them, please let me know.
If you want to contribute, there’s a few things that will help:
- If there’s anything in there that doesn’t make sense, particularly in the introductions, let me know.
- Noticed a useful parsing or expansion pattern? Also let me know.
- Have a useful bit of macro code that can be factored into a stand-alone macro? See above. (Actually, if the “Building Blocks” chapter gets significantly larger, I’ll be tempted to have a matching cargo crate so that they’re all immediately usable).
- Is there a big, complicated macro that you’d like to see explained (or better yet: you have an annotated version of a big, complicated macro)? You know the drill.