- 1 Getting Started
- lnstallation
- Hello, World!
- Hello, Cargo!
- 2 Programming a Guessing Game
- 3 Common Programming Concepts
- Variables and Mutability
- Data Types
- Functions
- Comments
- Control Flow
- 4 Understanding Ownership
- What is Ownership?
- References and Borrowing
- The Slice Type
- 5 Using Structs to Structure Related Data
- Defining and Instantiating Structs
- En Example Program Using Structs
- Method Syntax
- 6 Enums and Pattern Matching
- Defining an Enum
- The
match
Control Flow Operator
- Concise Control Flow with
if let
- 7 Managing Growing Projects with Packages, Crates, and Modules
- Pacakging and Crates
- Defining Modules to Control Scope and Privacy
- Paths for Referring to an Item in the Module Tree
- Bringing Paths Into Scope with the
use
Keyword
- Separating Modules into Different Files
- 8 Common Collections
- Storing Lists of Values with Vectors
- Storing UTF-8 Encoded Text with Strings
- Storing Keys with Associated Values in Hash Maps
- 9 Error Handling
- Unrecoverable Errors with
panic!
- Recoverable Errors with
Result
- To
panic!
or not to panic!
- 10 Generic Types, Trraits and Lifetimes
- Generic Data Types
- Traits: Defining Shared Behaviour
- Validating References with Lifetimes
- 11 Writing Automated Tests
- How to Write Tests
- Controlling How Tests are Run
- Test Organization
- 12 An I/O Project: Building a Command Line Program
- Accepting Command Line Arguments
- Reading a File
- Refactoring to Improve Modularity and Error Handling
- Developing the Library's Functionality with Test Driven Development
- Working with Environment Variables
- Writing Error Messages to Standard Error instead of Standard Output
- 13 Functional Language Features: Iterators and Closures
- Closures: Anonymous Functions that Can Capture Their Environment
- Processing a Series of Items with Iterators
- Improving our I/O Project
- Comparing Performance: Loops vs Iterators
- 14 More About Cargo and Crates.io
- Customizing Builds with Release Profiles
- Publishing a Crate to Crates.io
- Cargo Workspaces
- Installing Binaries from Crates.io with
cargo install
- 15 Smart Pointers
- Using
Box
to Point to Data on the Heap
- Treating Smart Pointers Like Regular References with the
Deref
Trait
- Running Code on Cleanup with the
Drop
Trait
Rc
the Reference Counted Smart Pointer
RefCell
and the Interior Mutability Pattern
- Reference Cycles Can Leak Memory
- 16 Fearless Concurrency
- Using Threads to Run Code Simultaneously
- Using Message Passing to Transfer Data Between Threads
- Shared-State Concurrency
- Extensible Concurrency with the
Sync
and Send
Traits
- 17 Object-Oriented Programming Features of Rust
- Characteristics of Object-Oriented Languages
- Using Trait Objects That Allow for Values of Different Types
- Implementing an Object-Oriented Design Pattern
- 18 Patterns and Matching
- All the Places Patterns Can Be Used
- Refutability: Whether a Pattern Might Fail to Match
- Pattern Syntax
- 19 Advanced Features
- Unsafe Rust
- Advanced Traits
- Advanced Types
- Advanced Functions and Closures
- Macros
- 20 Final Project: Building a Multithreaded Web Server
- Building a Single-Threaded Web Server
- Turning our Single-Threaded Server into a Multithreaded Server
- Graceful Shutdown and Cleanup
- 21 Appendix
- A Keywords
- B Operators and Symbols
- C Derivable Traits
- D Useful Development Tools
- E Editions
- F Translations of the Book
- G How Rust is Made and "Nightly Rust"