---
title: "Chapter 24: Macros"
description: "The 4 lessons of chapter 24: Macros, in teaching order."
url: "https://learnrust.net/chapter-24/"
last_updated: "2026-06-13"
---

# Chapter 24: Macros

- [24.1 Declarative macros: macro_rules!](https://learnrust.net/chapter-24/declarative-macros.md): Code that writes code: how macro_rules! matches patterns and expands into source, paying off the println! mystery from lesson 1.1.
- [24.2 When to write a macro](https://learnrust.net/chapter-24/when-to-write-a-macro.md): Choosing a macro only when a function or generic can't do the job, plus a first look at macro hygiene.
- [24.3 Procedural macros: an overview](https://learnrust.net/chapter-24/procedural-macros-overview.md): The three kinds of procedural macro behind derive, attributes, and function-like macros, what powers serde and tokio, and why you read them more than write them.
- [24.x Chapter 24 summary and quiz](https://learnrust.net/chapter-24/chapter-24-summary-and-quiz.md): Review of declarative macro_rules! macros, when to use a macro versus a function or generic, and the three kinds of procedural macro.

## Sitemap

See the full [sitemap](https://learnrust.net/sitemap.md) for all pages.
