Whole-book reading guide from stratified index samples; jump to passages in the text
Tip the Site
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat Pay
Alipay
Open WeChat or Alipay and scan. No login required.
AI guide
# Rust 程序设计语言 简体中文版 (The Rust Programming Language, 2e)
## 【One-Line Pitch】
The definitive, community-maintained guide to Rust, taking you from your first `Hello, world!` through ownership, traits, and building real projects — essential reading for any programmer serious about systems programming, whether you're coming from C, Python, or JavaScript.
## 【Book Arc】
- **Opening (~0%–10%)**: Installation, Cargo basics (`new`, `build`, `run`, `check`), and a complete "Guessing Game" project that introduces variables, input/output, and `match` — a fast, hands-on on-ramp that shows Rust's workflow before diving into theory.
- **Early (~10%–23%)**: Core language fundamentals — variables and mutability, control flow, and the pivotal ownership system (stack vs. heap, borrowing, slices) — followed by structs and enums, establishing the mental model that makes Rust unique.
- **Early-to-Middle (~23%–32%)**: Modules and privacy for organizing crates, plus collections (String, Vec, HashMap) with their pitfalls, and error handling — `panic!`, `Result`, and the `?` operator — teaching you to write robust, production-ready code.
- **Middle (~39%–48%)**: Generics, traits, and lifetimes — the abstraction toolkit — followed by a thorough testing chapter covering unit tests, integration tests, and test organization, showing how to verify behavior as you build.
- **Late (~48% onward)**: A capstone project (building a `grep`-like tool) that synthesizes everything learned, demonstrating how to structure a real binary crate with `src/main.rs` and `src/lib.rs` separation for testability.
## 【Key Takeaways】
- **Cargo is your constant companion** (Opening): `cargo new`, `build`, `run`, and `check` form a fast feedback loop; `cargo check` skips binary generation for quicker compile validation, and `cargo doc --open` gives you local dependency docs. This workflow is identical across all operating systems.
- **Ownership is Rust's third way to manage memory** (Early): Unlike garbage collection or manual allocation, Rust uses compile-time rules — values have a single owner, and when that owner goes out of scope, memory is freed. This gives you safety without runtime overhead.
- **Stack vs. heap determines behavior** (Early): Stack data needs known, fixed sizes; heap data uses pointers and requires allocation. Understanding this distinction explains why Rust makes the design choices it does — pushing to the stack is fast, while heap access requires pointer indirection.
- **Borrowing rules prevent dangling references** (Early): At any time, you can have either one mutable reference or multiple immutable references — never both. References must always be valid, which the compiler enforces, eliminating an entire class of memory bugs.
- **`match` is exhaustive by design** (Early): Rust's compiler checks that all possible cases are covered — for example, `Option<T>` forces you to handle `None`. This turns a billion-dollar class of null-pointer bugs into a compile-time error.
- **Traits enable abstraction with coherence** (Middle): You can implement your traits for any type, but the orphan rule prevents implementing external traits on external types — ensuring other people's code can't break yours, and vice versa.
- **Lifetimes describe relationships, not durations** (Middle): Lifetime annotations like `'a` don't change how long references live; they tell the borrow checker how multiple references relate, enabling it to verify your code's validity.
- **Testing is built into the workflow** (Middle): `#[test]` attributes, `cargo test`, unit tests in modules, and integration tests in a `tests/` directory — with the key insight that binary crates need a `src/lib.rs` companion to be testable from integration tests.
## 【Reading Tips】
- **Skim the Guessing Game chapter** (~3%–10%): It's a great warm-up, but don't get bogged down — the real meat starts with ownership. Come back to it if you need a refresher on Cargo basics.
- **Deep-read the ownership chapter** (~10%–13%): This is the hardest conceptual leap for most programmers. Read it slowly, work through the examples, and expect to re-read it. The stack/heap analogy (restaurant seating) is worth internalizing.
- **Pay attention to compiler errors**: The book shows real error messages throughout — these are teaching tools. Reading them carefully will train you to understand Rust's diagnostics, which are among the best in any language.
- **Do the exercises, don't just read**: The book builds projects incrementally (Guessing Game, then a grep clone). Type the code yourself, break it, and fix it — that's where the learning happens.
- **Use the testing chapter as a reference** (~42%–48%): You don't need to master every testing feature upfront, but know it's there. The distinction between unit tests (private internals) and integration tests (public API) is a key insight for structuring projects.
## 【Coverage Limits】
This guide covers the book's first half (through ~48%), including fundamentals, ownership, structs/enums, modules, collections, error handling, generics/traits/lifetimes, and testing. The excerpts do not cover the later project chapters, concurrency, smart pointers, or advanced features — those require reading the book directly.
##
rait `std::fmt::Display` is not implemented for `Rectangle` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty- print) instead 让我们来...
`dev` profile [unoptimized + debuginfo] target(s) in 0.27s Running `target/debug/panic` thread 'main' panicked at src/main.rs:4:6: index out of bounds: the l...
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.
Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat PayAlipay
Open WeChat or Alipay and scan. No login required.
Add Tag
Enter tag name (max 50 characters)
Share E-Book
Rust 程序设计语言 简体中文版(The Rust Programming Language (2e)) (Steve Klabnik, Carol Nichols)(Z-Library)
Scan QR code with your phone to access
Copy the link or scan the QR code to access this e-book on your phone
Share E-Book via Email
Please enter email address
Donation Statistics
¥.00
Total Donations
0
Donation Count
Rust 程序设计语言 简体中文版(The Rust Programming Language (2e)) (Steve Klabnik, Carol Nichols)(Z-Library)
Find Your Favorite Books
Only registered users can comment after logging in. Comments need to be reviewed by administrators before being displayed
Loading comments...
Reply to Comment
Edit Comment