Brief Table of Contents (Not Yet Final)....5
1. A Tour of Rust....7
rustup and Cargo....8
Rust Functions....11
Writing and Running Unit Tests....14
Handling Command-Line Arguments....15
Serving Pages to the Web....21
Concurrency....30
What the Mandelbrot Set Actually Is....32
Parsing Pair Command-Line Arguments....38
Mapping from Pixels to Complex Numbers....41
Plotting the Set....44
Writing Image Files....46
A Concurrent Mandelbrot Program....48
Safety Is Invisible....59
2. Fundamental Types....61
Numeric Types....65
Integer Types....66
Handling Integer Overflow....70
Floating-Point Types....73
The bool Type....76
Tuples....77
Pointer Types....79
Arrays, Vectors, and Slices....81
Arrays....82
Vectors....83
Slices....88
String and Character Types....90
String and Character Literals....90
Characters and Strings in Memory....93
String....96
Using Strings....99
Other String-Like Types....100
Type Aliases....102
Beyond the Basics....102
3. Ownership and Moves....103
Ownership....105
Moves....114
More Operations That Move....124
Moves and Control Flow....126
Moves and Indexed Content....127
Copy Types: The Exception to Moves....131
Rc and Arc: Shared Ownership....135
4. References....140
References to Values....141
Working with References....146
Rust References Versus C References....146
Assigning References....148
References to References....149
Comparing References....150
References Are Never Null....151
Borrowing References to Arbitrary Expressions....152
References to Slices and Trait Objects....153
Reference Safety....153
Borrowing a Local Variable....154
Receiving References as Function Arguments....160
Passing References to Functions....163
Returning References....164
Structs Containing References....165
Distinct Lifetime Parameters....169
Omitting Lifetime Parameters....171
Sharing Versus Mutation....173
Taking Arms Against a Sea of Objects....186
5. Expressions....189
An Expression Language....189
Operator Precedence and Associativity....191
Blocks....196
Declarations....198
if and match....201
if let....204
let else....205
Loops....206
break and continue Expressions....208
return Expressions....210
Why Rust Has loop....211
Function and Method Calls....213
Fields and Elements....215
Reference Operators....218
Arithmetic, Bitwise, Comparison, and Logical Operators....218
Assignment....220
Type Casts....220
Closures....222
Onward....223
About the Authors....224
Rust combines low-level control with memory safety, making it an ideal choice for systems programming. This practical guide is for experienced programmers looking to write fast, reliable code while avoiding common pitfalls like data races and buffer overflows. Authors Jim Blandy, Jason Orendorff, and Leonora Tindall explain Rust's unique approach to ownership, borrowing, and concurrency, helping you build safe, high-performance applications.
Fully updated for Rust's 2024 edition, this book introduces the latest language advancements while covering essential topics like generics, async programming, and C interoperability. Whether you're working on low-latency systems, embedded software, or multithreaded applications, this edition equips you with the knowledge to write efficient, production-ready Rust code.