Phase 1 of 4 · Study weeks 1-4
Ownership, safe code and a small unsafe module
This phase makes the first checkpoint possible: a core that the compiler, the tests and Miri all accept.
Topics every week
- Week 18 h
- Ownership, borrowing and lifetimes
- Structs, enums and pattern matching
OptionandResult- Error types and
?
Hand inThe record codec with a typed error and 20 tests
- Week 28 h
- Traits and generics
- Iterators and closures
- Smart pointers (
Box,Rc,Arc) - Interior mutability and its cost
Hand inAn in-memory index with a trait for storage and a test with a fake
- Week 38 h
- What
unsafeallows and the rules it still has - Raw pointers, aliasing and validity
- Miri and what it checks
- The unsafe-code guidelines
Hand inA 120-line
unsafearena with a written safety argument for each block - What
- Week 48 h
- Property tests
- Fuzzing with
cargo-fuzz - Clippy and the lint set
- The storage comparison
Hand inCheckpoint 1: the safe core, the fuzz run, the Miri run and the comparison table
Practice projects
- Practice 1, the borrow checker lab (Week 1): write five small programs the compiler rejects (a use after move, two mutable borrows, a reference that outlives its owner). Done when: each has the error message, a one-line reason in your words and a fix.
- Practice 2, the codec (Week 2): encode and decode a record with a length prefix and a checksum. Done when: a property test round-trips 100,000 random records and every truncated input returns an error, not a panic.
- Practice 3, the arena (Week 3): build the
unsafearena. Done when: Miri passes, a comment above eachunsafeblock states the invariant it relies on, and removing one invariant makes a test or Miri fail. - Optional, a
Dropguard: release a resource on all paths. Done when: a test shows the cleanup runs on an early return and on a panic.
GitHub repos to study
Existence and last commit were checked on 22 Nov 2026 by shallow clone. Every repository below had a commit in the last 12 months. Look at the README for archive notices before you rely on one.
| Repo | What to read | Week |
|---|---|---|
| rust-lang/rust | The standard library's Vec and RawVec, for unsafe style | 3 |
| rust-lang/miri | What it detects and the flags that make it stricter | 3 |
| rust-lang/rust-clippy | The lint groups and how correctness lints are chosen | 4 |
| rust-fuzz/cargo-fuzz | How a fuzz target is laid out and run | 4 |
| BurntSushi/ripgrep | A well-tested crate layout: error handling and tests | 2 |
Milestone checkpoint
Build Checkpoint 1. Write the codec tests and the fuzz target first. Add the index and the arena. Seed the stale-index bug and write down whether the compiler or a test caught it. Hand in the comparison table with your own numbers, the Miri and fuzz output, ADR-1 (error types) and ADR-2 (storage and unsafe).
Check yourself
Answer each question in your head first, then open it to check.
What does the borrow checker guarantee, and what does it not?
It guarantees no data races and no use of freed memory in safe code. It does not guarantee no leaks, no deadlocks and no logic bugs.What does
unsafeturn off, and what stays on?It lets you dereference raw pointers and call unsafe functions. Types, borrow rules for safe references and the aliasing rules still hold, and breaking them is undefined behaviour.What does Miri catch that tests and the compiler miss?
Undefined behaviour inunsafecode in the run: invalid references, aliasing violations and out-of-bounds access.When do you choose
Rcand whenArc?Rcwhen the value stays on one thread.Arcwhen it crosses threads, at the cost of atomic counting.Why can a property test find a bug that example tests miss?
It tries inputs across a large space, including ones you did not think of, and shrinks a failing case to a small one.