🦀 Learn Rust — From Zero to Pro
A comprehensive, edge-case-covering, idiomatic Rust curriculum. Each document is self-contained and teaches with short, simple examples, followed by tricky cases and edge cases — the code a beginner is likely to get wrong. Every example output was checked against Rust 1.97 (edition 2024).
- Read sequentially for a structured path (01 → 35).
- Jump to a chapter as a reference when you hit a concept in the wild.
- Run the exercises in chapter 35 after every few chapters.
- Read the source of std and
tokio alongside.
- A working Rust toolchain (
rustup). - A code editor (VS Code +
rust-analyzer recommended). - Comfort with at least one other programming language.
| # | Topic | Why It Matters |
|---|
| 01 | Introduction & Setup | Toolchain, cargo, project layout. |
| 02 | Hello World & Cargo Deep Dive | Cargo.toml, dependencies, workspaces. |
| 03 | Variables & Mutability | Immutability, shadowing, const, static. |
| 04 | Data Types | Integers, floats, char, tuples, arrays, casts. |
| 05 | Functions | Statements vs expressions, divergence, impl. |
| 06 | Control Flow | if/while/for/loop/match as expressions. |
| # | Topic | Why It Matters |
|---|
| 11 | Structs | Named/tuple/unit, impl, derives. |
| 12 | Enums | ADTs, Option, Result, niche optimization. |
| 13 | Pattern Matching | All pattern forms, binding modes, guards. |
| 14 | Collections | Vec, String, HashMap, and friends. |
| # | Topic | Why It Matters |
|---|
| 19 | Smart Pointers | Box/Rc/Cell/RefCell/Weak, cycles. |
| 20 | Modules & Crates | Visibility, paths, use, workspaces. |
| 21 | Testing | Unit/integration/doc tests, should_panic, parallel-test traps. |
| # | Topic | Why It Matters |
|---|
| 24 | Macros | macro_rules!, repetition, hygiene, double-evaluation trap. |
| 25 | Unsafe Rust | Raw pointers, safe wrappers, soundness, Miri. |
| 26 | FFI | Calling C, CString/CStr, exporting Rust, panics across FFI. |
| # | Topic | Why It Matters |
|---|
| 27 | Attributes & Conditional Compilation | #[cfg], #[derive], lints, #[non_exhaustive]. |
| 28 | Cargo Features & Release Engineering | Features, optional deps, profiles, build scripts. |
| 29 | Advanced Type System | Associated types, operators, const generics, PhantomData, ?Sized, dyn rules. |
| 30 | Design Patterns & Idiomatic Rust | Builder, typestate, newtype, RAII. |
| 31 | Performance, Profiling & Optimization | Release-mode timing, black_box, hidden O(n²) loops, profiling. |
| 32 | Documentation | rustdoc, doc tests, intra-doc links. |
| 33 | Ecosystem Tour | serde, clap, anyhow/thiserror, logging, choosing crates. |
| 34 | Common Pitfalls & Idiomatic Fixes | 26 short traps with fixes, in one page. |
| 35 | Exercises & Project Ideas | Predict-the-output warm-up, exercises with solutions, projects. |
- Read 01–14 in order.
- Skip to 21 (Testing) and write tests for everything you've built.
- Skim 15–18 and 22–23, then come back to the harder parts.
- Do exercises 1–5 in chapter 35.
Read 07–10 carefully (ownership is the new mental model). Skim 04 (data types) — you'll find surprises (char is 4 bytes). Read 25 (Unsafe) to understand what Rust adds over C. Then 22 and 23.
Ownership will be new. Read 03–10 slowly. Don't skip 18 (Error Handling) — Result/? is the culture. Don't reach for clone reflexively.
Skim 01–14. Read 16, 18, 22, 23, 27, 28 closely. Use 30, 34 as references. Skim 33 for the crate landscape. Then read 35 and pick a project.
rustup component add rustfmt clippy rust-src rust-analyzer
cargo install cargo-expand cargo-nextest cargo-deny cargo-audit \
cargo-flamegraph cargo-bloat cargo-machete cargo-release \
samply cargo-watch mdbook
These notes are yours to use, share, and modify.
🦀