Rust is a new systems programming language that combines the performance and low-level control of C and C++ with memory safety and thread safety. Rustâ s modern, flexible types ensure your program is free of null pointer dereferences, double frees, dangling pointers, and similar bugs, all at compile time, without runtime overhead. In multi-threaded code, Rust catches data races at compile time, making concurrency much easier to use. Written by two experienced systems programmers, this book explains how Rust manages to bridge the gap between performance and safety, and how you can take advantage of it. Topics include: How Rust represents values in memory (with diagrams) Complete explanations of ownership, moves, borrows, and lifetimes Cargo, rustdoc, unit tests, and how to publish your code on crates.io, Rustâ s public package repository High-level features like generic code, closures, collections, and iterators that make Rust productive and flexible Concurrency in Rust: threads, mutexes, channels, and atomics, all much safer to use than in C or C++ Unsafe code, and how to preserve the integrity of ordinary code that uses it Extended examples illustrating how pieces of the language fit together
AI Reading Assistant
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
# Programming Rust: Fast, Safe Systems Development
## 【One-Line Pitch】
A comprehensive, deeply technical guide to Rust for experienced systems programmers who want to understand how the language achieves memory safety and thread safety without sacrificing performance, covering everything from ownership and lifetimes to concurrency and unsafe code.
## 【Book Arc】
- **Opening (~0%–9%)**: Establishes Rust's core value proposition—combining C/C++ performance with compile-time memory and thread safety—and introduces the fundamental concept of type safety versus undefined behavior, contrasting Rust with C, C++, and Python.
- **Early (~9%–25%)**: A practical tour of Rust through working examples (GCD calculator, Mandelbrot set), introducing Cargo, basic syntax, structs, generics, and the standard library, while building intuition for how Rust represents values in memory.
- **Early (~25%–34%)**: Deep dive into basic types—integers, floats, arrays, slices, strings, and vectors—with precise range tables and memory layout details, establishing the foundation for understanding ownership.
- **Middle (~34%–47%)**: The heart of the book: ownership, moves, borrows, and lifetimes. Explains why Rust's move semantics differ from C++ and Python, how Copy types work, and how exclusive mutable references prevent entire classes of bugs including data races.
- **Middle (~47%–end of sample)**: Continues with references and lifetimes in depth, showing how lifetime parameters in type definitions reveal borrowing relationships, and introduces control flow constructs (if let, while let, loops) that work with Rust's pattern matching.
## 【Key Takeaways】
- **Type safety is Rust's core promise** (Opening): Unlike C and C++, Rust guarantees that well-typed programs never exhibit undefined behavior—null dereferences, double frees, and dangling pointers are caught at compile time, not runtime. This eliminates entire categories of security vulnerabilities.
- **Rust's type system is the safety mechanism** (Early): The language doesn't rely on runtime checks or garbage collection; instead, compile-time analysis of how values are used ensures memory safety with zero runtime overhead, making it suitable for systems programming.
- **Move semantics make costs explicit** (Middle): Rust's assignment and parameter passing perform shallow byte-for-byte copies that leave the source uninitialized, unlike C++'s customizable copy/move constructors. This makes expensive operations like deep copies (via `clone`) explicit and predictable.
- **Copy types are a deliberate design choice** (Middle): Types that implement `Copy` (like integers) are more flexible in usage but severely limited in what they can contain—heap-allocated data like `String` cannot be `Copy`, forcing programmers to think about ownership transfer.
- **Exclusive mutable references prevent whole bug classes** (Middle): Rust's rule that mutable access must be exclusive eliminates self-assignment bugs, invalidated iterator issues, and overlapping `memcpy` problems—all manifestations of the same underlying mistake that C++ programmers encounter regularly.
- **Data races are impossible by construction** (Middle): Because shared and mutable references cannot coexist, concurrent Rust code that avoids `unsafe` is free from data races at compile time, making concurrency dramatically safer than in C or C++.
- **Lifetime parameters reveal borrowing relationships** (Middle): A type's lifetime parameters expose whether it contains references with non-static lifetimes, making the borrowing structure of complex types visible and checkable at compile time.
## 【Reading Tips】
- **Skim the opening chapters** (~0%–9%) if you're already convinced Rust is worth learning; the value proposition and type safety discussion are useful but not where the practical content lives.
- **Deep-read the ownership and references chapters** (~34%–47%): This is the conceptual core of Rust and the hardest material for newcomers. Work through the memory diagrams carefully—they're essential for understanding why moves and borrows work the way they do.
- **Use the early examples as hands-on practice**: The GCD calculator and Mandelbrot set programs (Early chapters) are excellent for getting comfortable with Cargo, basic syntax, and the standard library before tackling harder concepts.
- **Pay attention to the C++ comparisons**: The book frequently contrasts Rust with C++ behavior (assignment, references, constructors). If you know C++, these comparisons accelerate understanding; if not, they're still illuminating but can be skimmed.
- **Don't skip the type tables** (Early, ~25%): The integer ranges and memory layout details matter for systems programming, but you can return to them as reference material rather than memorizing upfront.
## 【Coverage Limits】
The excerpts cover roughly the first half of the book (through references and control flow). Topics like generics, traits, closures, iterators, collections, concurrency in depth, and unsafe code are mentioned but not covered in the available material.
##
stalls a copy on your computer when you install Rust itself. You can view the standard library documenta‐ tion in your browser with the command: $ rustup doc...
etail. For now it will suffice to point out that a &str can refer to any slice of any string, whether it is a string literal (stored in the executable) or a...
It turns out that two classic C++ bugs—failure to cope with self-assignment, and using invalidated iterators—are the same underlying kind of bug! In both cas...
n recursively. For example, the source code for version 0.6.1 of the image crate contains a Cargo.toml file that includes this: [dependencies] byteorder = "0...
orrow parts of a matched value. & patterns match references. We’ll cover ref patterns first. Matching on a noncopyable value moves the value. Continuing with...
e that Rust’s function val‐ ues are exactly the same thing. After all this, it may come as a surprise that closures do not have the same type as functions: 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
Programming Rust (Jim Blandy, Jason Orendorff) (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
Programming Rust (Jim Blandy, Jason Orendorff) (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