Creating Your Own Macros

In previous chapters, we saw how macros and metaprogramming, in general, can make your life much easier. We saw both, macros that reduce the required boilerplate code and macros that will speed up your final code. It's time for you to learn how to create your own macros.

In this chapter, you will learn how to create your own standard macros, how to create your own procedural macros and custom derives, and finally, how to use nightly features to create your own plugins. You will also see how the new declarative macros work.

The chapter is divided into three sections:

  • Macrosystem: Understanding the macro_rules!{} macro
  • Procedural macros: Learning how to create your own custom derives
  • Nightly metaprogramming: Plugins ...

Get Rust High Performance 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.