1 Going meta

This chapter covers

  • What metaprogramming is
  • Metaprogramming in Rust
  • When to use macros
  • What this book will teach you

Macros are some of the most important and powerful tools Rust has to offer. Because they have powers that Rust’s normal tooling (like functions) lacks, they can serve as “a light in dark places when all other lights go out.” That of itself is enough to make macros a core topic of this book. They have another neat quality though: they can be a pathway to other abilities. When you want to write a macro, you need knowledge of testing and debugging. You have to know how to set up a library because you cannot write a procedural macro without creating a library. Some knowledge about Rust internals, compilation, types, ...

Get Write Powerful Rust Macros now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.