更新时间:2021-07-02 15:31:03
coverpage
Title Page
Second Edition
Copyright
Rust Essentials
Credits
About the Author
About the Reviewer
www.PacktPub.com
Why subscribe?
Customer Feedback
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Customer support
Downloading the example code
Errata
Piracy
Questions
Starting with Rust
The advantages of Rust
The trifecta of Rust - safe fast and concurrent
Comparison with other languages
The stability of Rust and its evolution
The success of Rust
Where to use Rust
Servo
Installing Rust
rustc--the Rust compiler
Our first program
Working with Cargo
Developer tools
Using Sublime Text
The Standard Library
Summary
Using Variables and Types
Comments
Global constants
Printing with string interpolation
Values and primitive types
Consulting Rust documentation
Binding variables to values
Mutable and immutable variables
Scope of a variable and shadowing
Type checking and conversions
Aliasing
Expressions
The stack and the heap
Using Functions and Control Structures
Branching on a condition
Looping
Functions
Documenting a function
Attributes
Conditional compilation
Testing
Testing with cargo
The tests module
Structuring Data and Matching Patterns
Strings
Arrays vectors and slices
Vectors
Slices
Strings and arrays
Tuples
Structs
Enums
Result and Option
Getting input from the console
Matching patterns
Program arguments
Higher Order Functions and Error-Handling
Higher order functions and closures
Iterators
Consumers and adapters
Generic data structures and functions
Error-handling
Panics
Testing for failure
Some more examples of error-handling
The try! macro and the ? operator
Using Traits and OOP in Rust
Associated functions on structs
Methods on structs
Using a constructor pattern
Using a builder pattern
Methods on tuples and enums
Traits
Using trait constraints
Static and dynamic dispatch
Built-in traits and operator overloading
OOP in Rust
Inheritance with traits