Building Rust's Standard Library from Scratch
Learn by building. Understand Rust's core types by implementing them yourself, from simple enums to async runtime internals.
libr0 takes you through Rust's fundamental types from scratch. Each chapter builds on the previous one, showing you exactly how Option, Box, Vec, Rc, and more work under the hood.
The simplest enum. Pattern matching with Some(T) and None.
Error handling with Ok(T) and Err(E). The ? operator.
First heap allocation. Stack vs heap, Deref trait.
Growable arrays. Why String is just Vec<u8>.
Interior mutability with UnsafeCell under the hood.
Runtime borrow checking with guard types.
Reference counting for shared ownership.
Shared mutable state. Build graphs and trees.
Box? Just alloc + dealloc in a struct. RefCell? Just a counter and panic! We show you exactly how it works.
What's in memory? Show the layout. What does the CPU do? Explain the instruction.
Every concept has runnable examples. Understanding comes from code, not theory.
We call out common misunderstandings explicitly with clear explanations.