目录
Preface
1. Why Rust?
Type Safety
2. A Tour of Rust
Downloading and Installing Rust
A Simple Function
Writing and Running Unit Tests
Handling Command-Line Arguments
A Simple Web Server
Concurrency
What the Mandelbrot Set Actually Is
Parsing Pair Command-Line Arguments
Mapping from Pixels to Complex Numbers
Plotting the Set
Writing Image Files
A Concurrent Mandelbrot Program
Running the Mandelbrot Plotter
Safety Is Invisible
3. Basic Tvpes
Machine Types
Integer Types
Floating-Point Types
The bool Type
Characters
Tuples
Pointer Types
References
Boxes
Raw Pointers
Arrays, Vectors, and Slices
Arrays
Vectors
Building Vectors Element by Element
Slices
String Types
String Literals
Byte Strings
Strings in Memory
String
Using Strings
Other String-Like Types
Beyond the Basics
4. Ownership
Ownership
Moves
More Operations That Move
Moves and Control Flow
Moves and Indexed Content
Copy Types: The Exception to Moves
Rc and Arc: Shared Ownership
5. References
References as Values
Rust References Versus C++ References
Assigning References
References to References
Comparing References
References Are Never Null
Borrowing References to Arbitrary Expressions
References to Slices and Trait Objects
Reference Safety
Borrowing a Local Variable
Receiving References as Parameters
Passing References as Arguments
Returning References
Structs Containing References
6. Expressions
7. Error Handing
8. Crates and modules
9. Structs
10. Enums and patterns
11. Traits and generics
12. Operator overloading
13. Utility traits
14 Cloures
15. Iterators
16. Collections
17. Strings and text
18. Input and Output
19. Concurrency
20. Nacros
21. Unsafe code
Index