Share E-Book
Scan to open this page

Scan with your phone to open this page

Author: Steve Klabnik, Carol Nichols

Rating No ratings yet

The official book on the Rust programming language, written by the Rust development team at the Mozilla Foundation, fully updated for Rust 2018. The Rust Programming Language is the official book on Rust: an open source systems programming language that helps you write faster, more reliable software. Rust offers control over low-level details (such as memory usage) in combination with high-level ergonomics, eliminating the hassle traditionally associated with low-level languages. The authors of The Rust Programming Language, members of the Rust Core Team, share their knowledge and experience to show you how to take full advantage of Rust's features--from installation to creating robust and scalable programs. You'll begin with basics like creating functions, choosing data types, and binding variables and then move on to more advanced concepts, such as: • Ownership and borrowing, lifetimes, and traits • Using Rust's memory safety guarantees to build fast, safe programs • Testing, error handling, and effective refactoring • Generics, smart pointers, multithreading, trait objects, and advanced pattern matching • Using Cargo, Rust's built-in package manager, to build, test, and document your code and manage dependencies • How best to use Rust's advanced compiler with compiler-led programming techniques You'll find plenty of code examples throughout the book, as well as three chapters dedicated to building complete projects to test your learning: a number guessing game, a Rust implementation of a command line tool, and a multithreaded server. New to this edition: An extended section on Rust macros, an expanded chapter on modules, and appendixes on Rust development tools and editions.

AI Reading Assistant

Whole-book reading guide from stratified index samples; jump to passages in the text

AI guide
【One-Line Pitch】 The official, community-maintained introduction to Rust that takes you from your first `cargo new` to a working multithreaded server, teaching the ownership model that makes Rust's safety guarantees click. Best for programmers coming from another language who want a structured, example-driven path into systems programming. 【Book Arc】 - **Opening (~0%–12%)**: Front matter, foreword, and introduction establish who Rust is for and what the book promises—installation, tooling, and the philosophy of compiler-led learning. - **Early (~12%–31%)**: Hands-on fundamentals—a guided guessing game, then variables, types, functions, and control flow—so you write runnable code before hitting the hard ideas. - **Middle (~31%–58%)**: The conceptual core: ownership, structs, enums and `match`, modules and crates, collections, error handling, then generics, traits, and lifetimes. This is where the language's mental model is built. - **Late (~58%–85%)**: Applied and advanced material—automated tests, a command-line I/O project, iterators and closures, Cargo/crates.io, smart pointers, fearless concurrency, OOP-style patterns, and advanced pattern matching. - **Ending (~85%–100%)**: Advanced features (macros, unsafe, and more) capped by the final project—a multithreaded web server—plus appendices on keywords, operators, derivable traits, dev tools, and editions. 【Key Takeaways】 - **Ownership is the spine of the book** (Middle): the rules governing moves, borrowing, and drops explain why Rust prevents whole classes of memory bugs without a garbage collector—master this before anything else. - **The compiler is a teaching partner** (Early): the book deliberately walks you through compiler errors and fixes, framing "fighting the borrow checker" as a learning loop rather than an obstacle. - **Types carry meaning** (Middle): enums with data, `Option<T>` over null, and custom validation types show how Rust pushes correctness into the type system so invalid states are hard to represent. - **Error handling is explicit and layered** (Middle): `Result`, `panic!`, and the `?`-style propagation are presented with guidelines for when to recover versus abort, plus custom types for validation. - **Generics, traits, and lifetimes work together** (Middle): traits define shared behavior, bounds constrain generics, and lifetimes validate references—treated as one connected toolkit, not isolated features. - **Concurrency without fear** (Late): the ownership model extends to threads and shared state, so data races become compile-time errors rather than runtime surprises. - **Projects anchor the theory** (Early/Late): three build-along projects—guessing game, CLI tool, multithreaded server—turn abstract chapters into muscle memory. - **Tooling is first-class** (Late): Cargo for build/test/doc/dependencies, plus appendices on dev tools and editions, make the workflow part of the curriculum. 【Reading Tips】 - **Don't skip Chapter 4 (Ownership)**—slow down there; everything later assumes it. Re-read if borrow-checker errors feel mysterious. - **Type the code, don't just read it.** The examples and three projects are designed to be compiled; the compiler feedback is the actual lesson. - **Skim the front matter and appendices** on a first pass, then return to Appendix D (tools) and E (editions) when setting up a real project. - **Treat generics/traits/lifetimes (Ch. 10) as a checkpoint**—if it's shaky, pause before smart pointers and concurrency, which build on it. - **Use the CLI and server projects as integration tests** of your understanding; if you can build them unaided, you've absorbed the core. 【Coverage Limits】 This guide is synthesized from front matter, table of contents, and stratified excerpts; it maps the book's structure and themes but does not summarize individual code examples or chapter-level detail beyond what the excerpts show.
Excerpt 1
es, and appendixes on Rust development tools and editions. COVERS RUST 2018 T H E R U S T P R O G R A M M I N G L A N G U A G E S T E V E K L A B N I K and C...
View in text
Page 9
Chapter 11: Writing Automated Tests. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207 Chapter 12: An I/O Project: Building a Command L...
View in text
Page 12
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 Comparing the Guess to the Secret Number . . . . . . . . . . . . . . . . . . . . . . . . . . ....
View in text
Page 13
s with pub use . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 Using External Packages . . . . . . . . . . . . . . . . . . . . . . . . . ....
View in text
Page 15
_panic . . . . . . . . . . . . . . . . . . . . . . . . . . . 218 Using Result<T, E> in Tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ....
View in text
Page 17
. . . . . . . . . 326 Using Rc<T> to Share Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 327 Cloning an Rc<T> Increases the Refe...
View in text
Page 18
h the ... Syntax . . . . . . . . . . . . . . . . . . . . . . 404 Destructuring to Break Apart Values. . . . . . . . . . . . . . . . . . . . . . . . . . . . ....
View in text
Page 20
7 Debug for Programmer Output. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 508 PartialEq and Eq for Equality Comparisons ....
View in text
Tags
AI categories
Programming LanguageRustSoftware
ISBN: 1718500440
Publisher: No Starch Press
Publish Year: 2019
Language: English
Pages: 560
File Format: PDF
File Size: 8.7 MB
Text Preview (First 20 pages)
Registered users can read the full content for free

Register as a Gaohf Library member to read the complete e-book online for free and enjoy a better reading experience.

Generating text preview…