Introduction
Welcome to Rust 101 - a comprehensive collection of 101 exercises designed to take you from Rust beginner to confident Rustacean.
What Makes This Different?
Unlike micro-exercises like Rustlings, these exercises are:
- Substantial: Each exercise builds something real and satisfying
- Progressive: Concepts build naturally on each other
- Comprehensive: Forces you to use every Rust feature in context
- Practical: Skills transfer directly to real-world Rust programming
Structure
The 101 exercises are organized into 10 phases:
- Foundations (1-15): Basic syntax, ownership, simple collections
- Intermediate Collections (16-30): Advanced collection usage, patterns
- Error Handling & I/O (31-40): Result, Option, file operations
- Ownership Deep Dive (41-50): Lifetimes, borrowing, Cow
- Smart Pointers (51-65): Box, Rc, RefCell, Arc, Weak
- Trait System (66-75): Traits, generics, trait objects
- Advanced Patterns (76-85): Custom iterators, builder pattern, typestate
- Concurrency (86-92): Threads, channels, sync primitives
- Real-World Algorithms (93-100): Graph algorithms, DP, search
- Capstone (101): Complete compiler + VM with event loop
How to Use This Book
- Read the exercise - Understand what you're building
- Try it yourself - Write code without looking at hints
- Run the tests - Use
cargo test
to validate your solution - Peek at hints - If stuck, hints are in a separate section
- Compare solutions - After solving, see alternative approaches
- Do follow-ups - Extend the exercise with additional challenges
Prerequisites
- Basic programming experience (any language)
- Rust installed (
rustup
recommended) - Familiarity with command line
- A code editor (VS Code, RustRover, etc.)
Philosophy
These exercises teach Rust by:
- Forcing natural usage: You'll reach for
Rc<RefCell<T>>
because you need it, not because you memorized when to use it - Building intuition: Patterns emerge from solving real problems
- Embracing difficulty: Ownership errors teach better than explanations
- Celebrating progress: Each solved exercise is a real achievement
Ready to start? Head to Exercise 1: RPN Calculator!