1. Experiment Introduction
  2. The Rust Programming Language
  3. Foreword
  4. Introduction
  5. 1. Getting Started
    1. 1.1. Installation
    2. 1.2. Hello, World!
    3. 1.3. Hello, Cargo!
  6. 2. Programming a Guessing Game
  7. 3. Common Programming Concepts
    1. 3.1. Variables and Mutability
    2. 3.2. Data Types
    3. 3.3. Functions
    4. 3.4. Comments
    5. 3.5. Control Flow
  8. 4. Understanding Ownership
    1. 4.1. What is Ownership?
    2. 4.2. References and Borrowing
    3. 4.3. Fixing Ownership Errors
    4. 4.4. The Slice Type
  9. 5. Using Structs to Structure Related Data
    1. 5.1. Defining and Instantiating Structs
    2. 5.2. An Example Program Using Structs
    3. 5.3. Method Syntax
  10. 6. Enums and Pattern Matching
    1. 6.1. Defining an Enum
    2. 6.2. The match Control Flow Construct
    3. 6.3. Concise Control Flow with if let
    4. 6.4. Ownership Inventory #1
  11. 7. Managing Growing Projects with Packages, Crates, and Modules
    1. 7.1. Packages and Crates
    2. 7.2. Defining Modules to Control Scope and Privacy
    3. 7.3. Paths for Referring to an Item in the Module Tree
    4. 7.4. Bringing Paths Into Scope with the use Keyword
    5. 7.5. Separating Modules into Different Files
  12. 8. Common Collections
    1. 8.1. Storing Lists of Values with Vectors
    2. 8.2. Storing UTF-8 Encoded Text with Strings
    3. 8.3. Storing Keys with Associated Values in Hash Maps
    4. 8.4. Ownership Inventory #2
  13. 9. Error Handling
    1. 9.1. Unrecoverable Errors with panic!
    2. 9.2. Recoverable Errors with Result
    3. 9.3. To panic! or Not to panic!
  14. 10. Generic Types, Traits, and Lifetimes
    1. 10.1. Generic Data Types
    2. 10.2. Traits: Defining Shared Behavior
    3. 10.3. Validating References with Lifetimes
    4. 10.4. Ownership Inventory #3
  15. 11. Writing Automated Tests
    1. 11.1. How to Write Tests
    2. 11.2. Controlling How Tests Are Run
    3. 11.3. Test Organization
  16. 12. An I/O Project: Building a Command Line Program
    1. 12.1. Accepting Command Line Arguments
    2. 12.2. Reading a File
    3. 12.3. Refactoring to Improve Modularity and Error Handling
    4. 12.4. Developing the Library’s Functionality with Test Driven Development
    5. 12.5. Working with Environment Variables
    6. 12.6. Writing Error Messages to Standard Error Instead of Standard Output
  17. 13. Functional Language Features: Iterators and Closures
    1. 13.1. Closures: Anonymous Functions that Capture Their Environment
    2. 13.2. Processing a Series of Items with Iterators
    3. 13.3. Improving Our I/O Project
    4. 13.4. Comparing Performance: Loops vs. Iterators
  18. 14. More about Cargo and Crates.io
    1. 14.1. Customizing Builds with Release Profiles
    2. 14.2. Publishing a Crate to Crates.io
    3. 14.3. Cargo Workspaces
    4. 14.4. Installing Binaries from Crates.io with cargo install
    5. 14.5. Extending Cargo with Custom Commands
  19. 15. Smart Pointers
    1. 15.1. Using Box<T> to Point to Data on the Heap
    2. 15.2. Treating Smart Pointers Like Regular References with the Deref Trait
    3. 15.3. Running Code on Cleanup with the Drop Trait
    4. 15.4. Rc<T>, the Reference Counted Smart Pointer
    5. 15.5. RefCell<T> and the Interior Mutability Pattern
    6. 15.6. Reference Cycles Can Leak Memory
  20. 16. Fearless Concurrency
    1. 16.1. Using Threads to Run Code Simultaneously
    2. 16.2. Using Message Passing to Transfer Data Between Threads
    3. 16.3. Shared-State Concurrency
    4. 16.4. Extensible Concurrency with the Sync and Send Traits
  21. 17. Object Oriented Programming Features of Rust
    1. 17.1. Characteristics of Object-Oriented Languages
    2. 17.2. Using Trait Objects That Allow for Values of Different Types
    3. 17.3. Implementing an Object-Oriented Design Pattern
    4. 17.4. Ownership Inventory #4
  22. 18. Patterns and Matching
    1. 18.1. All the Places Patterns Can Be Used
    2. 18.2. Refutability: Whether a Pattern Might Fail to Match
    3. 18.3. Pattern Syntax
  23. 19. Advanced Features
    1. 19.1. Unsafe Rust
    2. 19.2. Advanced Traits
    3. 19.3. Advanced Types
    4. 19.4. Advanced Functions and Closures
    5. 19.5. Macros
  24. 20. Final Project: Building a Multithreaded Web Server
    1. 20.1. Building a Single-Threaded Web Server
    2. 20.2. Turning Our Single-Threaded Server into a Multithreaded Server
    3. 20.3. Graceful Shutdown and Cleanup
  25. 21. End of Experiment
  26. 22. Appendix
    1. 22.1. A - Keywords
    2. 22.2. B - Operators and Symbols
    3. 22.3. C - Derivable Traits
    4. 22.4. D - Useful Development Tools
    5. 22.5. E - Editions
    6. 22.6. F - Translations of the Book
    7. 22.7. G - How Rust is Made and “Nightly Rust”

The Rust Programming Language

Appendix F: Translations of the Book

For resources in languages other than English. Most are still in progress; see the Translations label to help or let us know about a new translation!

  • Português (BR)
  • Português (PT)
  • 简体中文
  • 正體中文
  • Українська
  • Español, alternate
  • Italiano
  • Русский
  • 한국어
  • 日本語
  • Français
  • Polski
  • Cebuano
  • Tagalog
  • Esperanto
  • ελληνική
  • Svenska
  • Farsi
  • Deutsch
  • Turkish, online
  • हिंदी
  • ไทย
  • Danske