更新时间:2021-07-02 13:36:18
coverpage
Title Page
Copyright and Credits
Mastering Rust Second Edition
About Packt
Why subscribe?
Packt.com
Contributors
About the author
About the reviewer
Packt is searching for authors like you
Preface
Who this book is for
What this book covers
Getting the most out of this book
Download the example code files
Conventions used
Get in touch
Reviews
Getting Started with Rust
What is Rust and why should you care?
Installing the Rust compiler and toolchain
Using rustup.rs
A tour of the language
Primitive types
Declaring variables and immutability
Functions
Closures
Strings
Conditionals and decision making
Match expressions
Loops
User-defined types
Structs
Enums
Functions and methods on types
Impl blocks on structs
Impl blocks for enums
Modules imports and use statements
Collections
Arrays
Tuples
Vectors
Hashmaps
Slices
Iterators
Exercise – fixing the word counter
Summary
Managing Projects with Cargo
Package managers
Modules
Nested modules
File as a module
Directory as module
Cargo and crates
Creating a new Cargo project
Cargo and dependencies
Running tests with Cargo
Running examples with Cargo
Cargo workspace
Extending Cargo and tools
Subcommands and Cargo installation
cargo-watch
cargo-edit
cargo-deb
cargo-outdated
Linting code with clippy
Exploring the manifest file – Cargo.toml
Setting up a Rust development environment
Building a project with Cargo – imgtool
Tests Documentation and Benchmarks
Motivation for testing
Organizing tests
Testing primitives
Attributes
Assertion macros
Unit tests
First unit test
Running tests
Isolating test code
Failing tests
Ignoring tests
Integration tests
First integration test
Sharing common code
Documentation
Writing documentation
Generating and viewing documentation
Hosting documentation
Doc attributes
Documentation tests
Benchmarks
Built-in micro-benchmark harness
Benchmarking on stable Rust
Writing and testing a crate – logic gate simulator
Continuous integration with Travis CI
Types Generics and Traits
Type systems and why they matter