---
title: "Chapter 13: Modules, Crates, and Cargo"
description: "The 9 lessons of chapter 13: Modules, Crates, and Cargo, in teaching order."
url: "https://learnrust.net/chapter-13/"
last_updated: "2026-06-13"
---

# Chapter 13: Modules, Crates, and Cargo

- [13.1 Naming collisions, and why modules exist](https://learnrust.net/chapter-13/naming-collisions-and-modules.md): As programs grow, two pieces of code want the same name; modules are Rust's way to organize code into named scopes so names don't collide.
- [13.2 Defining modules and paths](https://learnrust.net/chapter-13/defining-modules.md): How to define nested modules, refer to items with absolute and relative paths (crate::, self::, super::), and bring names into scope with use.
- [13.3 Visibility: pub](https://learnrust.net/chapter-13/visibility-pub.md): Items are private by default; pub exposes them, pub(crate) limits exposure to the crate, and struct fields are made public one at a time, which is encapsulation.
- [13.4 Splitting code into multiple files](https://learnrust.net/chapter-13/splitting-code-into-files.md): Moving a module into its own file with mod foo and foo.rs, directory modules with mod.rs or named files: the one lesson that replaces C++'s entire header system.
- [13.5 Binary and library crates](https://learnrust.net/chapter-13/binary-and-library-crates.md): The difference between a binary crate (main.rs) and a library crate (lib.rs), having both in one package, and why the split matters for testing and reuse.
- [13.6 Cargo in depth](https://learnrust.net/chapter-13/cargo-in-depth.md): A tour of what Cargo does beyond run and build: profiles, useful commands, a glance at workspaces and features, and Cargo.toml as the project's control panel.
- [13.7 Documentation comments](https://learnrust.net/chapter-13/documentation-comments.md): Doc comments with /// and //!, Markdown in docs, building a docs website with cargo doc, and why Rust's documentation culture is one of its quiet strengths.
- [13.8 Reading documentation](https://learnrust.net/chapter-13/reading-documentation.md): How to actually read a method signature you've never seen on docs.rs and the standard library docs: a practical skill that makes you self-sufficient.
- [13.x Chapter 13 summary and quiz](https://learnrust.net/chapter-13/chapter-13-summary-and-quiz.md): Review of modules, paths, visibility, splitting code into files, crates, Cargo, and documentation, with a chapter quiz and a small organizational exercise.

## Sitemap

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