advanced path

Smart Pointers & Interior Mutability

Box, Rc, RefCell, Cow and Weak — what each one buys, what it costs, and the compile-time versus runtime borrow distinction that decides which one you actually need.

serves: Rust/C++ systems programming6 lessons · ~3.5h
progress0/6
Start track

// lessons

  1. 01

    Box<T> & Recursive Types

    Give a recursive enum a known size.

  2. 02

    Rc<T> & Shared Ownership

    Share one allocation between several owners on one thread.

  3. 03

    RefCell<T> & Runtime Borrowing

    Move a borrow check from compile time to runtime — and accept the panic that buys.

  4. 04

    Weak<T> & Reference Cycles

    Build a parent/child graph that actually gets freed.

  5. 05

    Cow<T> & Allocating Only When You Must

    Return borrowed data on the common path, owned on the rare one.

  6. 06

    Deref, DerefMut & Custom Pointers

    Make your own wrapper behave like the thing it wraps.

Every exercise compiles and runs in the Forge sandbox — standard library only, no external crates.