liveBook · Manning

What you will learn in Code Like a Pro in Rust

by Brenden Matthews

Chapter by chapter

Chapter 1: Feelin’ Rusty

1.1 What’s Rust? · 1.2 What’s unique about Rust? · 1.2.1 Rust is safe · 1.2.2 Rust is modern · 1.2.3 Rust is pure open source · 1.2.4 Rust vs. other popular languages · 1.3 When should you use Rust? · 1.3.1 Rust use cases · 1.4 Tools you’ll need · 1.5 Summary

What you learn in chapter 1 →

Chapter 2: Project management with Cargo

2.1 Cargo tour · 2.1.1 Basic usage · 2.1.2 Creating a new application or library · 2.1.3 Building, running, and testing · 2.1.4 Switching between toolchains · 2.2 Dependency management · 2.2.1 Handling the Cargo.lock file · 2.3 Feature flags · 2.4 Patching dependencies · 2.4.1 Indirect dependencies · 2.4.2 Best practices for dependency patching · 2.5 Publishing crates · 2.5.1 CI/CD integration · 2.6 Linking to C libraries · 2.7 Binary distribution · 2.7.1 Cross compilation · 2.7.2 Building statically linked binaries · 2.8 Documenting Rust projects · 2.8.1 Code examples in documentation · 2.9 Modules · 2.10 Workspaces · 2.11 Custom building scripts · 2.12 Rust projects in embedded environments · 2.12.1 Memory allocation · 2.13 Summary

What you learn in chapter 2 →

Chapter 3: Rust tooling

3.1 Overview of Rust tooling · 3.2 Using rust-analyzer for Rust IDE integration · 3.2.1 Magic completions · 3.3 Using rustfmt to keep code tidy · 3.3.1 Installing rustfmt · 3.3.2 Configuring rustfmt · 3.4 Using Clippy to improve code quality · 3.4.1 Installing Clippy · 3.4.2 Clippy’s lints · 3.4.3 Configuring Clippy · 3.4.4 Automatically applying Clippy’s suggestions · 3.4.5 Using Clippy in CI/CD · 3.5 Reducing compile times with sccache · 3.5.1 Installing sccache · 3.5.2 Configuring sccache · 3.6 Integration with IDEs, including Visual Studio Code · 3.7 Using toolchains: Stable vs. nightly · 3.7.1 Nightly-only features · 3.7.2 Using nightly on published crates · 3.8 Additional tools: cargo-update, cargo-expand, cargo-fuzz, cargo-watch, cargo-tree · 3.8.1 Keeping packages up to date date with cargo-update · 3.8.2 Debugging macros with cargo-expand · 3.8.3 Testing libFuzzer · 3.8.4 Iterating with cargo-watch · 3.8.5 Examining dependencies with cargo-tree · 3.9 Summary

What you learn in chapter 3 →

Chapter 4: Data structures

4.1 Demystifying String, str, &str, and &'static str · 4.1.1 String vs str · 4.1.2 Using strings effectively · 4.2 Understanding slices and arrays · 4.3 Vectors · 4.3.1 Diving deeper into Vec · 4.3.2 Wrapping vectors · 4.3.3 Types related to vectors · 4.4 Maps · 4.4.1 Custom hashing functions · 4.4.2 Creating hashable types · 4.5 Rust types: Primitives, structs, enums, and aliases · 4.5.1 Using primitive types · 4.5.2 Using tuples · 4.5.3 Using structs · 4.5.4 Using enums · 4.5.5 Using aliases · 4.6 Error handling with Result · 4.7 Converting types with From/Into · 4.7.1 TryFrom and TryInto · 4.7.2 Best practices for type conversion using From and Into · 4.8 Handling FFI compatibility with Rust’s types · 4.9 Summary

What you learn in chapter 4 →

Chapter 5: Working with memory

5.1 Memory management: Heap and stack · 5.2 Understanding ownership: Copies, borrowing, references, and moves · 5.3 Deep copying · 5.4 Avoiding copies · 5.5 To box or not to box: Smart pointers · 5.6 Reference counting · 5.7 Clone on write · 5.8 Custom allocators · 5.8.1 Writing a custom allocator · 5.8.2 Creating a custom allocator for protected memory · 5.9 Smart pointers summarized · 5.10 Summary

What you learn in chapter 5 →

Chapter 6: Unit testing

6.1 How testing is different in Rust · 6.2 Review of built-in testing features · 6.3 Testing frameworks · 6.4 What not to test: Why the compiler knows better than you · 6.5 Handling parallel test special cases and global state · 6.6 Thinking about refactoring · 6.7 Refactoring tools · 6.7.1 Reformatting · 6.7.2 Renaming · 6.7.3 Relocating · 6.7.4 Rewriting · 6.8 Code coverage · 6.9 Dealing with a changing ecosystem · 6.10 Summary

What you learn in chapter 6 →

Chapter 7: Integration testing

7.1 Comparing integration and unit testing · 7.2 Integration testing strategies · 7.3 Built-in integration testing vs. external integration testing · 7.4 Integration testing libraries and tooling · 7.4.1 Using assert_cmd to test CLI applications · 7.4.2 Using proptest with integration tests · 7.4.3 Other integration testing tools · 7.5 Fuzz testing · 7.6 Summary

What you learn in chapter 7 →

Chapter 8: Async Rust

8.1 Runtimes · 8.2 Thinking asynchronously · 8.3 Futures: Handling async task results · 8.3.1 Defining a runtime with #[tokio::main] · 8.4 The async and .await keywords: When and where to use them · 8.5 Concurrency and parallelism with async · 8.6 Implementing an async observer · 8.7 Mixing sync and async · 8.8 When to avoid using async · 8.9 Tracing and debugging async code · 8.10 Dealing with async when testing · 8.11 Summary

What you learn in chapter 8 →

Chapter 9: Building an HTTP REST API service

9.1 Choosing a web framework · 9.2 Creating an architecture · 9.3 API design · 9.4 Libraries and tools · 9.5 Application scaffolding · 9.5.1 main() · 9.5.2 init_tracing() · 9.5.3 init_dbpool() · 9.6 Data modeling · 9.6.1 SQL schema · 9.6.2 Interfacing with our data · 9.7 Declaring the API routes · 9.8 Implementing the API routes · 9.9 Error handling · 9.10 Running the service · 9.11 Summary

What you learn in chapter 9 →

Chapter 10: Building an HTTP REST API CLI

10.1 Deciding which tools and libraries to use · 10.2 Designing the CLI · 10.3 Declaring the commands · 10.4 Implementing the commands · 10.5 Implementing requests · 10.6 Handling errors gracefully · 10.7 Testing our CLI · 10.8 Summary

What you learn in chapter 10 →

Chapter 11: Optimizations

11.1 Zero-cost abstractions · 11.2 Vectors · 11.2.1 Vector memory allocation · 11.2.2 Vector iterators · 11.2.3 Fast copies with Vec and slices · 11.3 SIMD · 11.4 Parallelization with Rayon · 11.5 Using Rust to accelerate other languages · 11.6 Where to go from here · 11.7 Summary

What you learn in chapter 11 →

Concepts explained in this book

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.