---
title: "Chapter 21: Smart Pointers"
description: "The 8 lessons of chapter 21: Smart Pointers, in teaching order."
url: "https://learnrust.net/chapter-21/"
last_updated: "2026-06-13"
---

# Chapter 21: Smart Pointers

- [21.1 Introduction to smart pointers](https://learnrust.net/chapter-21/introduction-to-smart-pointers.md): What a smart pointer is: a value that owns what it points to and adds behavior, and why Box, Rc, and RefCell exist when plain references don't suffice.
- [21.2 Box<T>](https://learnrust.net/chapter-21/box.md): The simplest smart pointer: heap allocation for a single value, and the recursive types whose infinite-size error Box exists to fix.
- [21.3 Deref and deref coercion](https://learnrust.net/chapter-21/deref-and-deref-coercion.md): The Deref trait that lets a smart pointer stand in for its contents, and the deref coercion that finally explains why &String works as &str.
- [21.4 Drop in depth](https://learnrust.net/chapter-21/drop-in-depth.md): The Drop trait behind automatic cleanup, the order values are dropped in, dropping early with std::mem::drop, and the RAII pattern named.
- [21.5 Rc<T>](https://learnrust.net/chapter-21/rc.md): The reference-counted smart pointer for shared ownership: many owners of one value, freed when the last one drops, with clone-the-handle semantics.
- [21.6 RefCell and interior mutability](https://learnrust.net/chapter-21/refcell-and-interior-mutability.md): Moving the borrow check to runtime with RefCell, mutating through a shared reference safely, and the Rc<RefCell<T>> combination.
- [21.7 Reference cycles and Weak](https://learnrust.net/chapter-21/reference-cycles-and-weak.md): The one memory leak Rust doesn't prevent: two Rcs pointing at each other, and how Weak references break the cycle.
- [21.x Chapter 21 summary and quiz](https://learnrust.net/chapter-21/chapter-21-summary-and-quiz.md): Review of Box, Deref, Drop, Rc, RefCell, and Weak, the smart pointers and traits that let you reach for the heap and share ownership deliberately.

## Sitemap

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