---
title: "Chapter 5: Constants, Shadowing, and Strings"
description: "The 7 lessons of chapter 5: Constants, Shadowing, and Strings, in teaching order."
url: "https://learnrust.net/chapter-5/"
last_updated: "2026-06-12"
---

# Chapter 5: Constants, Shadowing, and Strings

- [5.1 Constants and statics](https://learnrust.net/chapter-5/constants-and-statics.md): Declaring compile-time constants with const, naming them, hunting magic numbers, and the two paragraphs static deserves.
- [5.2 Shadowing](https://learnrust.net/chapter-5/shadowing.md): Rebinding a name with let, why shadowing isn't mutation, and the type-changing idiom Rust programmers use everywhere.
- [5.3 Introduction to String](https://learnrust.net/chapter-5/introduction-to-string.md): Rust's owned, growable text type: creating Strings, growing them with push_str, and what len() really counts.
- [5.4 Introduction to &str](https://learnrust.net/chapter-5/introduction-to-str.md): String literals unmasked: the borrowed string type, why trim never copies, and how to choose function parameter types.
- [5.5 Formatting strings](https://learnrust.net/chapter-5/formatting-strings.md): format! and the formatting mini-language: width, alignment, precision, zero-padding, and the {:?} debug view.
- [5.6 Parsing strings into numbers](https://learnrust.net/chapter-5/parsing-strings-into-numbers.md): The read-a-number incantation taken apart: trim, parse, the turbofish, and what happens when the user types potato.
- [5.x Chapter 5 summary and quiz](https://learnrust.net/chapter-5/chapter-5-summary-and-quiz.md): Constants, shadowing, String and &str, formatting and parsing reviewed, plus a quiz that uses the whole chapter at once.

## Sitemap

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