Rust From Zero
Learn Rust from nothing to genuinely advanced: install it and the basics, then ownership - and then the deep half: lifetimes, traits and generics, smart pointers, error handling, fearless concurrency, iterators, macros, and performance and unsafe. Mental-model-first, with clear explanations.
Download EPUB- Install & Your First Program Install the Rust toolchain with rustup, confirm rustc and cargo are there, then create and run your first program with cargo new and cargo run - the workflow you'll use every day.
- Syntax, Values & Types let binds values and they're immutable by default (mut makes them changeable); Rust is statically typed but infers most types; meet i32, f64, bool, char, &str and String, plus shadowing.
- Collections Hold many values: Vec<T> is the growable list you'll use daily, arrays are fixed-size, HashMap stores key-value pairs - plus the String vs &str distinction that confuses everyone, finally explained.
- Control Flow & Functions Make decisions and bundle logic: if and match are expressions that produce values, loop/while/for cover repetition, match is exhaustive (the compiler forces you to handle every case), and functions return their last expression without writing return.
- Modules & Project Layout Organize a real project: what Cargo.toml, src/main.rs, and src/lib.rs are for; how mod creates modules, pub makes things public, and use brings names into scope; what a crate is and how to add one.
- Ownership & Borrowing - Rust's Big Idea Every value in Rust has exactly one owner; assigning or passing it moves ownership; you borrow with & (shared, many) or &mut (exclusive, one) - and that single set of rules gives memory safety with no garbage collector and no manual free.
- Errors & I/O - Failure in the Type System Rust puts failure and absence in the type itself: Result<T, E> for things that can fail and Option<T> for things that can be missing; you handle them with match or the ? operator, reserve panic! for truly unrecoverable bugs, and read files with std::fs.
- The Ecosystem & Tooling - Cargo Does Everything Cargo is the one tool you'll live in: it builds, runs, tests, and adds dependencies; Cargo.toml + crates.io manage your packages; rustfmt formats your code and clippy is the famously helpful linter that teaches you idiomatic Rust.
- Idioms & Common Gotchas - Writing Rust Like a Rustacean The handful of patterns that make code feel like real Rust - enums with exhaustive match, traits for shared behavior, iterator combinators (map/filter/collect), Option/Result combinators, and borrowing over cloning - plus a cheat-card of the gotchas that bite every newcomer.
- Lifetimes & the Borrow Checker, Deep - Making References Provable A reference must never outlive its data. Lifetimes are how the compiler proves that - a region of code, not a thing you create. Here's why functions sometimes need 'a, why you rarely write it (elision), references in structs, and what 'static really means.
- Traits & Generics, Deep - Shared Behavior Without Inheritance Traits define shared behavior; generics write code once for many types; together they give Rust polymorphism without inheritance. Default methods, trait bounds, monomorphization, associated types, static vs dynamic dispatch, and the orphan rule.
- Smart Pointers & Interior Mutability - Box, Rc, RefCell & Friends Ownership has one owner and compile-time borrow rules. Smart pointers bend those rules in controlled ways: Box for heap, Rc/Arc for shared ownership, RefCell to mutate through a shared reference - and Deref/Drop are the machinery underneath.
- Error Handling, Deep - Result, ?, and Custom Errors Go past the basics: what ? really does, how the From trait makes errors flow through one operator, hand-rolled error enums, and the thiserror/anyhow split that real Rust projects rely on.
- Fearless Concurrency - Threads the Compiler Keeps Safe Rust's ownership rules extend to threads, so the compiler rejects data races at compile time. Here's spawning threads, why naive sharing won't compile, Arc<Mutex<T>>, the Send/Sync marker traits, channels, and a taste of async.
- Closures, Iterators & Zero-Cost Abstractions - Expressive and Fast Closures capture their environment, the Fn/FnMut/FnOnce traits decide how, and the Iterator trait turns one tiny method into a whole pipeline - all compiling down to the same machine code as a hand-written loop, for free.
- Macros & Metaprogramming - Code That Writes Code Why println! has a bang, how macros run at compile time and expand into ordinary Rust, writing a small macro_rules!, when a declarative macro earns its keep, and the derive/procedural macros you'll actually use.
- Performance, Unsafe & the Ecosystem - The Last Mile Why Rust is fast without you trying, the one build flag everyone forgets, measuring before optimizing, what `unsafe` really unlocks (and what it doesn't), and the daily-driver crates worth knowing by name.
- Where to Go Next Straight signposts for what to build with Rust next - CLI tools, web servers, systems and embedded, WebAssembly - plus the official Book as the deep dive, and a reminder that the borrow checker stops fighting you sooner than you think.