knaxuslearn · build · ship

Roadmaps / Rust / Phase 1

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

  1. Week 18 h
    • Ownership, borrowing and lifetimes
    • Structs, enums and pattern matching
    • Option and Result
    • Error types and ?

    Hand inThe record codec with a typed error and 20 tests

  2. 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

  3. Week 38 h
    • What unsafe allows and the rules it still has
    • Raw pointers, aliasing and validity
    • Miri and what it checks
    • The unsafe-code guidelines

    Hand inA 120-line unsafe arena with a written safety argument for each block

  4. 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 unsafe arena. Done when: Miri passes, a comment above each unsafe block states the invariant it relies on, and removing one invariant makes a test or Miri fail.
  • Optional, a Drop guard: 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.

RepoWhat to readWeek
rust-lang/rustThe standard library's Vec and RawVec, for unsafe style3
rust-lang/miriWhat it detects and the flags that make it stricter3
rust-lang/rust-clippyThe lint groups and how correctness lints are chosen4
rust-fuzz/cargo-fuzzHow a fuzz target is laid out and run4
BurntSushi/ripgrepA well-tested crate layout: error handling and tests2

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.

  1. 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.
  2. What does unsafe turn 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.
  3. What does Miri catch that tests and the compiler miss?
    Undefined behaviour in unsafe code in the run: invalid references, aliasing violations and out-of-bounds access.
  4. When do you choose Rc and when Arc?
    Rc when the value stays on one thread. Arc when it crosses threads, at the cost of atomic counting.
  5. 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.