Metaprogramming with Macros

Metaprogramming is a concept that changes the way you look at instructions and data in a program. It allows you to generate new code by treating instructions like any other piece of data. Many languages have support for metaprogramming, for example, Lisp's macros, C's #define construct, and Python's metaclasses. Rust is no different and provides many forms of metaprogramming, which we'll explore in this chapter.

In this chapter, we will look at the following topics:

  • What is metaprogramming?
  • Macros in Rust and their forms
  • Declarative macros, macro variables, and types
  • Repeating constructs
  • Procedural macros
  • Macro use case
  • Available macro crates
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset