Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Cover Page
Title Page
Copyright Page
About the Authors
BRIEF CONTENTS
CONTENTS IN DETAIL
FOREWORD by Nicholas Matsakis and Aaron Turon
ACKNOWLEDGMENTS
INTRODUCTION
Who Rust Is For
Who This Book Is For
How to Use This Book
Resources and How to Contribute to This Book
1 GETTING STARTED
Installation
Hello, World!
Hello, Cargo!
Summary
2 PROGRAMMING A GUESSING GAME
Setting Up a New Project
Processing a Guess
Generating a Secret Number
Comparing the Guess to the Secret Number
Allowing Multiple Guesses with Looping
Summary
3 COMMON PROGRAMMING CONCEPTS
Variables and Mutability
Data Types
Functions
Comments
Control Flow
Summary
4 UNDERSTANDING OWNERSHIP
What Is Ownership?
References and Borrowing
The Slice Type
Summary
5 USING STRUCTS TO STRUCTURE RELATED DATA
Defining and Instantiating Structs
An Example Program Using Structs
Method Syntax
Summary
6 ENUMS AND PATTERN MATCHING
Defining an Enum
The match Control Flow Operator
Concise Control Flow with if let
Summary
7 USING MODULES TO REUSE AND ORGANIZE CODE
mod and the Filesystem
Controlling Visibility with pub
Referring to Names in Different Modules
Summary
8 COMMON COLLECTIONS
Storing Lists of Values with Vectors
Storing UTF-8 Encoded Text with Strings
Storing Keys with Associated Values in Hash Maps
Summary
9 ERROR HANDLING
Unrecoverable Errors with panic!
Recoverable Errors with Result
To panic! or Not to panic!
Summary
10 GENERIC TYPES, TRAITS, AND LIFETIMES
Removing Duplication by Extracting a Function
Generic Data Types
Traits: Defining Shared Behavior
Validating References with Lifetimes
Generic Type Parameters, Trait Bounds, and Lifetimes Together
Summary
11 WRITING AUTOMATED TESTS
How to Write Tests
Controlling How Tests Are Run
Test Organization
Summary
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
Summary
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
Summary
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
Extending Cargo with Custom Commands
Summary
15 SMART POINTERS
Using Box<T> 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<T>, the Reference Counted Smart Pointer
RefCell<T> and the Interior Mutability Pattern
Reference Cycles Can Leak Memory
Summary
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
Summary
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
Summary
18 PATTERNS AND MATCHING
All the Places Patterns Can Be Used
Refutability: Whether a Pattern Might Fail to Match
Pattern Syntax
Summary
19 ADVANCED FEATURES
Unsafe Rust
Advanced Lifetimes
Advanced Traits
Advanced Types
Advanced Functions and Closures
Summary
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
Summary
A KEYWORDS
Keywords Currently in Use
Keywords Reserved for Future Use
B OPERATORS AND SYMBOLS
Operators
Non-operator Symbols
C DERIVABLE TRAITS
Debug for Programmer Output
PartialEq and Eq for Equality Comparisons
PartialOrd and Ord for Ordering Comparisons
Clone and Copy for Duplicating Values
Hash for Mapping a Value to a Value of Fixed Size
Default for Default Values
D MACROS
The Difference Between Macros and Functions
Declarative Macros with macro_rules! for General Metaprogramming
Procedural Macros for Custom derive
The Future of Macros
INDEX
← Prev
Back
Next →
← Prev
Back
Next →