Rust Mastery
Master Rust — ownership, borrowing, lifetimes, traits, error handling, async runtimes, unsafe FFI, and production tooling. 16 phases from toolchain setup to systems-programming interviews.
Your Progress
Complete all 16 phases to master this track
Master Rust — ownership, borrowing, lifetimes, traits, error handling, async runtimes, unsafe FFI, and production tooling. 16 phases from toolchain setup to systems-programming interviews.
Phase 1: Toolchain, Cargo, and Language Syntax
Install the Rust toolchain, create a Cargo project, and learn the core syntax and idioms that every crate follows.
Installing Rust with rustup
Manage stable, beta, and nightly toolchains and target triples with rustup.
Cargo Projects and Commands
Scaffold binaries and libraries and run the build, test, and run workflow.
Bindings, Mutability, and Shadowing
Declare immutable lets, opt into mut, and reuse names through shadowing.
Primitive Types and Overflow
Use sized integers, floats, chars, bools, tuples, and handle numeric overflow.
Formatting, Lints, and Documentation
Keep code consistent with rustfmt, catch issues with clippy, and build docs with rustdoc.
Phase 2: Ownership and Move Semantics
Apply the three ownership rules to track who frees every value and eliminate use-after-free bugs at compile time.
The Three Ownership Rules
Understand how each value has exactly one owner that drops it at end of scope.
Move Semantics in Practice
Predict when assignment and function calls move values and invalidate old bindings.
Stack and Heap Allocation
See where values live and why Strings allocate while string literals do not.
Copy and clone Traits
Mark simple types as implicitly copyable and opt into explicit deep clones.
Partial Moves and Field Ownership
Work with struct fields that move individually while other fields stay usable.
Phase 3: Borrowing, References, and the Borrow Checker
Share data with references while the borrow checker proves no alias is ever mutated or used after free.
Shared References
Lend values with ampersand to read them without taking ownership.
Slices as Fat References
Borrow contiguous ranges of arrays and strings with &[T] and &str.
Mutable References
Lend exclusive access for writes under the single-mutator rule.
The Borrow Checker Rules
Apply the aliasing rules across scopes to reason about compiler rejections.
Refactoring Borrow Checker Errors
Resolve common rejections with scoping, cloning, and restructuring data.
Phase 4: Lifetimes and Bounds
Annotate and elide lifetimes so the compiler can prove references outlive everything that uses them.
Lifetime Annotations
Write named lifetimes that state how input and output references relate.
Lifetime Elision Rules
Let the compiler infer lifetimes for common function and method signatures.
The static Lifetime
Distinguish the longest-lived lifetime from static items and global data.
Holding References in Structs
Declare lifetime parameters so structs may borrow data from their owners.
Lifetime Bounds and Outlives Relations
Constrain multiple lifetimes and generics with outlives relationships.
Phase 5: Enums, Option, Result, and Pattern Matching
Model domain states as enums and eliminate null and exceptions through exhaustive pattern matching.
Enumerations with Data
Declare enums whose variants each carry their own payload types.
match Expressions
Branch on values with exhaustive arms that the compiler forces you to cover.
Option and the End of Null
Represent possibly-absent values with Some and None and unwrap them safely.
Result for Fallible Work
Return Ok and Err values so failure cases stay visible in every signature.
Destructuring and Nested Patterns
Pull apart structs, enums, tuples, and ranges with rich patterns and guards.
Phase 6: Structs, Traits, and Trait Bounds
Define data with structs and shared behavior with traits, then constrain generics with trait bounds.
Structs and Field Syntax
Group related data with named, tuple, and unit struct definitions.
impl Blocks and Methods
Attach methods with self receivers and associated functions like constructors.
Traits and Implementations
Define shared method signatures and implement them for any compatible type.
Generic Trait Bounds
Constrain type parameters with impl Trait syntax and where clauses.
Trait Objects and Dynamic Dispatch
Store heterogeneous values behind dyn Trait and pay for runtime dispatch.
Phase 7: Error Handling with Result
Propagate failures with the question mark operator and design typed error enums for libraries and binaries.
unwrap, expect, and When Panics Are Acceptable
Know the panic cost of unwrap and where expect earns its place.
Option Combinators
Chain map, and_then, and defaults instead of nested match statements.
The question mark Operator
Early-return Err values and convert error types through the From trait.
Implementing the Error Trait
Build custom error enums with Display and source chaining for libraries.
anyhow for Applications, thiserror for Libraries
Choose the right error crate strategy based on who consumes the errors.
Phase 8: Collections and Iterators
Choose the right collection type and chain lazy iterator adapters for expressive data processing.
Vec and Dynamic Arrays
Grow and index vectors while reasoning about capacity and reallocation.
String and str
Move between owned String and borrowed str and handle UTF-8 correctly.
HashMap and BTreeMap
Store key-value data with hashing or sorted iteration depending on needs.
Iterator Adapters
Chain map, filter, enumerate, and collect into typed results.
Custom Iterators and Laziness
Implement the Iterator trait and understand why chains cost nothing until used.
Phase 9: Modules, Crates, and Cargo Workspaces
Structure code into modules and crates, manage dependencies, and split large projects into workspaces.
Modules and Visibility
Split code across files with mod and control access with pub levels.
use Paths and Aliases
Bring items into scope with absolute and relative paths and rename imports.
Dependencies in Cargo.toml
Declare crate versions, features, and dev-only dependencies correctly.
Cargo Workspaces for Multi-Crate Repos
Split a project into cooperating crates that share one lockfile and target directory.
Feature Flags and Optional Dependencies
Gate optional functionality and compile-time configuration with features.
Phase 10: Declarative and Procedural Macros
Extend the compiler with macro rules patterns and build derive and attribute macros for generated code.
macro_rules! Fundamentals
Write declarative macros with matchers, metavariables, and expansion rules.
Repetition, Hygiene, and Macro Patterns
Repeat captured fragments with star and plus and avoid identifier capture bugs.
Attribute Macros
Attach custom attributes to functions and types to transform them in place.
How Procedural Macros Work
Set up a proc-macro crate with quote and syn to generate code as strings of tokens.
Building a Custom derive
Generate trait implementations automatically from a derive attribute.
Phase 11: Smart Pointers and Interior Mutability
Manage shared and unique heap data with Box, Rc, and RefCell while keeping the borrow rules enforced.
Box for Heap Allocation
Put values on the heap and enable recursive data structures.
Deref Coercion
Let smart pointers transparently convert to their targets at call boundaries.
Rc for Shared Ownership
Reference-count a value across multiple owners in single-threaded code.
Cell, RefCell, and Interior Mutability
Mutate data behind a shared reference while enforcing rules at runtime.
Reference Cycles and Weak
Break parent-child cycles that would otherwise leak memory forever.
Phase 12: Threads, Channels, and Shared State
Run parallel work with threads and message passing while satisfying the Send and Sync contracts.
Spawning Threads
Start OS threads with std thread and join their results.
Moving Data into Threads
Give spawned closures ownership of their data with the move keyword.
Message Passing with mpsc
Send values between threads through multiple-producer single-consumer channels.
Arc and Mutex for Shared State
Share mutable data across threads with atomic counts and exclusive locks.
Send and Sync Marker Traits
Understand the compiler-enforced thread-safety contracts behind parallel APIs.
Phase 13: Async Rust with Tokio
Write futures with async await, drive them on a tokio runtime, and handle timeouts and cancellation safely.
async fn and await
Declare futures and poll them to completion without blocking the thread.
The Tokio Runtime
Bootstrap async programs with tokio main and spawn tasks on the scheduler.
join! and select! for Concurrent Futures
Run futures together and race them with branch-based control flow.
Timeouts, Cancellation, and Async I/O
Bound async operations and understand why cancellation must be safe.
Pin and Unpin Explained
See why self-referential futures need pinned memory locations to poll safely.
Phase 14: Unsafe Rust and FFI
Step outside the compiler guarantees deliberately and interface with C while documenting every safety invariant.
The unsafe Keyword
Learn the four capabilities unlocked inside unsafe blocks and their costs.
Raw Pointers
Create and dereference const and mut raw pointers under explicit invariants.
FFI with C Libraries
Declare extern functions and repr C layouts for cross-language calls.
Encapsulating Unsafe with Invariants
Hide unsafe details behind safe APIs with documented preconditions.
Common Unsoundness Patterns
Recognize aliasing, lifetime, and validity bugs that unsafe code can introduce.
Phase 15: Testing, Benchmarks, and Profiling
Organize unit and integration tests, measure performance with criterion, and find hot spots with flamegraphs.
Unit Tests and Assertions
Write #[test] functions with the standard assertion macros and should-panic checks.
Integration Tests and Test Layout
Place tests in the tests directory and share helpers through modules.
Test Doubles with Traits
Abstract dependencies behind traits and provide in-memory fakes for tests.
Benchmarks with Criterion
Measure throughput and regressions with statistical benchmarking output.
Profiling with Flamegraphs and Perf
Sample stack frames to locate CPU and allocation hot spots visually.
Phase 16: Systems Projects and Interview Preparation
Apply ownership, concurrency, and unsafe knowledge in capstone projects and answer classic systems interview questions.
Production Crate Baseline
Set up CI lint gates, MSRV policy, and cross-compilation for releases.
Ownership and Borrowing Interview Drills
Trace move and borrow errors on paper before reaching for the compiler.
Async and Concurrency Interview Drills
Reason about Send, Sync, futures, and executor behavior under questioning.
CLI Tool Capstone
Build a command-line search or parsing tool with clap, iterators, and error types.
Concurrent Service Capstone
Implement a thread-pool or key-value service using channels, Arc, and graceful shutdown.