A quick guide to some of the major Rust topics we’ll learn about in
my Mastery sessions, organised by
subject area.
Data and ownership
Places and values
- Ownership
- Move semantics vs copy semantics
Copy and Clone
clone and clone_from
- The borrow checker
- Dropping and the
Drop trait
Variables and mutability
- Immutability by default
mut variables
- Interior mutability:
Cell and RefCell
References and memory
- Shared vs mutable references
- References vs cloning
as_ref
- Indeferences
- Niche optimisation
NonNull and NonZero
std::mem tools: take,
replace, swap
- Stack vs heap allocation
Lifetimes
- Lifetimes in data structures
- RAII (Resource Acquisition Is Initialization) pattern
- Lifetime elision
- Naming lifetimes
PhantomData<T>
Expressions
- Rust is an expression language
- Block and function values
Safety and correctness
unsafe and safety comments
- Raw pointers
- Checked arithmetic
- Overflow behaviour
- Rounding
- Conversions with
From, TryFrom, and
FromStr
must_use
Data types
Working with data
- Numeric types
- Literals
- Type inference
- Casting and conversion
serde and serialization
- The unit type
()
Collections
- Arrays and
Vecs
HashMap and HashSet
- The
Entry API for HashMap
VecDeque
Composite types
- Slices
- Structs
- Enums
- Tuples
Option types
Option
Result
unwrap and expect
Patterns
- Patterns and
match
- Match guards
- Refutable and irrefutable patterns
- Pattern binding
- Destructuring
Defining types
- Methods
- The
self parameter and the Self type
impl Trait in argument position
- Upcasting and downcasting:
Any, is,
type_id, and downcast_ref
- Type aliases
- The newtype pattern
Strings
String vs &str
- UTF-8
OsStr and OSString
Constants and statics
const and static
LazyLock / LazyCell
- Const functions
Generics
- Type parameters
- Trait bounds
where clauses
- Generic types
- Generic traits
- Blanket implementations
- Smart pointers:
Box<T> etc.
- Trait objects:
dyn Trait,
Box<dyn Trait>, and &dyn Trait
- Dyn compatibility
Traits
Defining traits
- The orphan rule
- Default implementations
- Associated types
- Associated functions
- Supertraits and subtraits
- Disambiguating overlapping traits
Standard traits
- Deriving traits
Default
PartialEq and Eq
PartialOrd and Ord
Read and Write
println!
- Format language
Debug and Display
Control flow
Scope
- Blocks
- Scopes and visibility
- Shadowing
Conditionals
- The
? operator
if let, while let, and
let ... else
Loops
loop and break
while loops
for loops
- Loops over iterators
- Labels and
break LABEL
break VALUE
continue
Functions and closures
- Defining functions
- Parameters and return values
- Closures and capturing
- Function types and values
Fn, FnMut, and FnOnce
- Higher order functions
- Diverging functions and the never type
Iterators
map
Iterator and IntoIter
impl Iterator in return position
collect and collecting into Result
- Iterator methods
- Iterator adapters
- Iterator combinators
- Ranges
Errors and error handling
panic! and unwinding
eprintln!
anyhow and thiserror
Concurrency
Rc and RefCell
Arc and Mutex
- Threads
async and await
- Async runtimes and executors
- Tokio and
smol
- Futures
- Streams
- Channels
rustup
- Clippy
- Compiler lints
rust-analyzer
- IDEs and LSP integration
- Zed debugger
dbg!
Compiler control
- Attributes
cfg and conditional compilation
codegen-units
- Optimization
- Inlining
- Build timings and graphs
build.rs
Crates and modules
Cargo.toml
- Packages and crates
- Workspaces
- Modules
- File hierarchy for modules
use declarations
use *
pub use
- Prelude modules
super
Features
- Defining features
- Chaining features
- The
default feature and
--no-default-features
Documentation
cargo doc
- Doctests
- Documentation comments
- Intra-doc links
Publishing
crates.io
cargo publish
- Breaking changes and
cargo-semver-check
dev and release profiles
- Rust editions
- Minimum Rust versions
Dependencies
- Dependency tree
- Dependency metadata:
path, git,
rev, and branch
- Custom registries
Program design
- Builder pattern
macro_rules macros
derive macros
Testing
- Tests
assert_eq! etc
- Integration tests
- Dev dependencies
Applications
Operating system
Path and PathBuf
clap
- Reading and writing files with
fs
- Processes
- Testing CLIs
env! and option_env!
include_str! and include_bytes!
Standard (and de facto
standard) library
Interoperability
- C/C++ interop
repr and struct layout
- Inline assembly
- Target tuples and cross-compilation
Embedded development
no_std crates
core vs alloc
- Allocator API
probe-rs
- Embassy and HALs