This repository contains the source of "The Rust Programming Language" book.
The book is available in dead-tree form from No Starch Press.
You can also read the book for free online. Please see the book as shipped with the latest stable, beta, or nightly Rust releases. Be aware that issues in those versions may have been fixed in this repository already, as those releases are updated less frequently.
See the releases to download just the code of all the code listings that appear in the book.
If you are using this repository to learn Rust, not just to build or edit the book, we recommend studying it with an agent that can work inside the repo and load local skills.
This repository includes a rust-book-tutor skill for guided, interactive
learning based on The Rust Programming Language. It is especially useful if
you want:
- chapter-by-chapter study instead of jumping between isolated questions
- explanations tailored to your programming background
- progress tracking between sessions
- a Chinese-language tutoring flow with interactive follow-up questions
Open the repository in your agent from the repository root, then start the tutor with either the skill name or a natural-language request.
Direct skill entry:
load_skill rust-book-tutor
Natural-language entry examples:
Use rust-book-tutor and help me start learning Rust from Chapter 1.
Use rust-book-tutor and teach me ownership and borrowing step by step.
During onboarding, the tutor asks a few short questions about your experience
and goals, then saves progress in .learning-progress.json so the next session
can resume where you left off.
If you only came with a one-off Rust question, that can still work well—but if
you find yourself asking repeated questions about concepts like ownership,
borrowing, lifetimes, traits, or error handling, starting rust-book-tutor is
the better path for systematic learning.
Building the book requires mdBook, ideally the same version that rust-lang/rust uses in this file. To get it:
$ cargo install mdbook --locked --version <version_num>To build the book, type:
$ mdbook buildThe output will be in the book subdirectory. To check it out, open it in
your web browser.
Firefox:
$ firefox book/index.html # Linux
$ open -a "Firefox" book/index.html # OS X
$ Start-Process "firefox.exe" .\book\index.html # Windows (PowerShell)
$ start firefox.exe .\book\index.html # Windows (Cmd)Chrome:
$ google-chrome book/index.html # Linux
$ open -a "Google Chrome" book/index.html # OS X
$ Start-Process "chrome.exe" .\book\index.html # Windows (PowerShell)
$ start chrome.exe .\book\index.html # Windows (Cmd)To run the tests:
$ cargo build --manifest-path packages/trpl/Cargo.toml
$ mdbook test --library-path packages/trpl/target/debug/depsWe'd love your help! Please see CONTRIBUTING.md to learn about the kinds of contributions we're looking for.
Because the book is printed, and because we want to keep the online version of the book close to the print version when possible, it may take longer than you're used to for us to address your issue or pull request.
So far, we've been doing a larger revision to coincide with Rust Editions. Between those larger revisions, we will only be correcting errors. If your issue or pull request isn't strictly fixing an error, it might sit until the next time that we're working on a large revision: expect on the order of months or years. Thank you for your patience!
We'd love help translating the book! See the Translations label to join in efforts that are currently in progress. Open a new issue to start working on a new language! We're waiting on mdbook support for multiple languages before we merge any in, but feel free to start!
To scan source files for spelling errors, you can use the spellcheck.sh
script available in the ci directory. It needs a dictionary of valid words,
which is provided in ci/dictionary.txt. If the script produces a false
positive (say, you used the word BTreeMap which the script considers invalid),
you need to add this word to ci/dictionary.txt (keep the sorted order for
consistency).