Foreword

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Introduction

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Getting Started

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Installation

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Hello, World!

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Hello, Cargo!

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Programming a Guessing Game

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Common Programming Concepts

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Variables and Mutability

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Data Types

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Functions

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Comments

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Control Flow

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Understanding Ownership

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

What Is Ownership?

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

References and Borrowing

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

The Slice Type

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Using Structs to Structure Related Data

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Defining and Instantiating Structs

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

An Example Program Using Structs

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Method Syntax

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Enums and Pattern Matching

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Defining an Enum

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

The match Control Flow Operator

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Concise Control Flow with if let

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Using Modules to Reuse and Organize Code

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

mod and the Filesystem

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Controlling Visibility with pub

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Referring to Names in Different Modules

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Common Collections

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Storing Lists of Values with Vectors

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Storing UTF-8 Encoded Text with Strings

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Storing Keys with Associated Values in Hash Maps

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Error Handling

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Unrecoverable Errors with panic!

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Recoverable Errors with Result

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

To panic! or Not to panic!

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Generic Types, Traits, and Lifetimes

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Generic Data Types

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Traits: Defining Shared Behavior

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Validating References with Lifetimes

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Writing Automated Tests

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

How to Write Tests

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Controlling How Tests Are Run

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Test Organization

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

An I/O Project: Building a Command Line Program

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Accepting Command Line Arguments

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Reading a File

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Refactoring to Improve Modularity and Error Handling

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Developing the Library’s Functionality with Test-Driven Development

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Working with Environment Variables

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Writing Error Messages to Standard Error Instead of Standard Output

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Functional Language Features: Iterators and Closures

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Closures: Anonymous Functions that Can Capture Their Environment

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Processing a Series of Items with Iterators

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Improving Our I/O Project

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Comparing Performance: Loops vs. Iterators

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

More About Cargo and Crates.io

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Customizing Builds with Release Profiles

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Publishing a Crate to Crates.io

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Cargo Workspaces

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Installing Binaries from Crates.io with cargo install

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Extending Cargo with Custom Commands

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Smart Pointers

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Using Box<T> to Point to Data on the Heap

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Treating Smart Pointers Like Regular References with the Deref Trait

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Running Code on Cleanup with the Drop Trait

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Rc<T>, the Reference Counted Smart Pointer

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

RefCell<T> and the Interior Mutability Pattern

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Reference Cycles Can Leak Memory

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Fearless Concurrency

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Using Threads to Run Code Simultaneously

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Using Message Passing to Transfer Data Between Threads

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Shared-State Concurrency

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Extensible Concurrency with the Sync and Send Traits

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Object Oriented Programming Features of Rust

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Characteristics of Object-Oriented Languages

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Using Trait Objects that Allow for Values of Different Types

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Implementing an Object-Oriented Design Pattern

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Patterns and Matching

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

All the Places Patterns Can Be Used

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Refutability: Whether a Pattern Might Fail to Match

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Pattern Syntax

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Advanced Features

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Unsafe Rust

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Advanced Lifetimes

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Advanced Traits

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Advanced Types

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Advanced Functions and Closures

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Final Project: Building a Multithreaded Web Server

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Building a Single-Threaded Web Server

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Turning Our Single-Threaded Server into a Multithreaded Server

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Graceful Shutdown and Cleanup

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Appendix

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Appendix A: Keywords

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Appendix B: Operators and Symbols

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Appendix C: Derivable Traits

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Appendix D: Macros

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Appendix E: Translations of the Book

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Appendix F - Newest Features

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.

Appendix G - How Rust is Made and “Nightly Rust”

The second edition of the book is no longer distributed with Rust's documentation.

If you came here via a link or web search, you may want to check out the current version of the book instead.

If you have an internet connection, you can find a copy distributed with Rust 1.30.