Lessons
Lifetimes and lifetime annotations
What lifetimes are, when annotations are needed, the 'a syntax, and lifetime elision rules.
Prerequisite: Practitioner track complete
What to look for:
- Lifetimes prevent dangling references — the compiler verifies this
- 'a in fn longest<'a>(x: &'a str, y: &'a str) -> &'a str
- Lifetime elision: most cases do not need explicit annotations
- struct with reference fields always need lifetime annotations
Smart pointers: Box, Rc, Arc
Box
Prerequisite: Lesson 1 of Advanced
What to look for:
- Box
: single owner, heap allocation - Rc
: multiple owners, single thread - Arc
: multiple owners, multiple threads (atomic reference count) - Rc
> pattern for shared mutable state
Threads, Mutex, and channels
thread::spawn, join handles, Arc
Prerequisite: Lesson 2 of Advanced
What to look for:
- thread::spawn(move || ...) — move ownership into thread
- Mutex lock guard is released when it goes out of scope (RAII)
- mpsc::channel() — multiple producers, one consumer
- Send and Sync marker traits — type system proof of thread safety
Async Rust and Tokio basics
async fn, await, futures are lazy, Tokio runtime, tokio::spawn, and async I/O.
Prerequisite: Lesson 3 of Advanced
What to look for:
- async fn returns a Future — nothing runs until awaited
- Futures are lazy: calling an async fn does nothing alone
- #[tokio::main] — Tokio provides the executor
- tokio::join! for concurrent awaiting — like Promise.all
unsafe and FFI
What unsafe unlocks, when to use it, calling C from Rust with extern "C", and the five unsafe superpowers.
Prerequisite: Lessons 1-4 of Advanced
What to look for:
- unsafe enables 5 things only: raw pointers, unsafe fns, mutable statics, unsafe traits, extern
- unsafe does NOT disable the borrow checker — it only unlocks these 5
- FFI: extern "C" { fn strlen(s: *const i8) -> usize; }
- Keep unsafe blocks small and well-documented
How to use this track: Each lesson links to the Codex Rust reference page. Use reading level tabs. Rust borrow checker errors are the lesson — read them carefully. Practice at play.rust-lang.org.
Track quiz
4 questions to check your understanding.
What do lifetime annotations ('a) tell the Rust compiler?
When would you use Arc
Why are Futures in Rust described as "lazy"?
What does unsafe in Rust actually enable?