7 days · 20 concepts
Rust / Concepts

Rust in a week

Twenty concept pages. Day 2 is the famous one — ownership, borrowing, lifetimes — and where Rust feels different from every other language. By Day 5 you're handling errors idiomatically; by Day 7 you're writing tested, cargo-managed code.


Day 1 · First contact

rustc, cargo, types — running code in 20 minutes.

  1. 01

    Hello, Rust

    rustc, cargo, the toolchain. Five minutes from install to running binary.

  2. 02

    Variables, types, mutability

    Immutable by default. let mut to opt in. Shadowing.

  3. 03

    Functions & control flow

    Expressions everywhere. if is an expression. match is the power tool.

Day 2 · The borrow checker

Ownership, borrowing, lifetimes. The week that hurts and pays off.

  1. 04

    Ownership

    Every value has one owner. Moving by default. Drop on scope exit.

  2. 05

    References & borrowing

    &T shared, &mut T exclusive. Never both at once.

  3. 06

    Lifetimes 101

    Mostly inferred. 'a annotations only when ambiguous.

Day 3 · Data shapes

Sum types, pattern matching, the canonical collections.

  1. 07

    Structs & enums

    enum is sum type. struct is product type. Both first-class.

  2. 08

    Pattern matching

    match is exhaustive. if let, while let. Destructure everything.

  3. 09

    Vec, HashMap, String

    Owned containers. &str borrows; String owns. The split that matters.

Day 4 · Polymorphism

Traits and generics. Static dispatch vs dyn.

  1. 10

    Traits

    Like Go interfaces but with explicit impl Trait for Type. Coherence.

  2. 11

    Generics

    Type parameters with trait bounds. Monomorphisation, not erasure.

  3. 12

    Trait objects (dyn)

    dyn Trait for dynamic dispatch. The cost: a vtable lookup.

Day 5 · Error handling

Result, Option, the ? operator. No exceptions; explicit error paths.

  1. 13

    Result & Option

    No exceptions. No null. Sum types for "maybe" and "succeeded".

  2. 14

    The ? operator

    Propagate errors in one character. The Go "if err != nil" — automated.

  3. 15

    Custom errors & thiserror

    Define an enum. Implement Error. Use thiserror for boilerplate.

Day 6 · Concurrency

Threads, Arc/Mutex, async/await. The Send/Sync invariants.

  1. 16

    Threads & sync

    Real OS threads. Arc<Mutex<T>> for shared state. Send + Sync invariants.

  2. 17

    async / await

    Futures, executors, tokio. Async is opt-in, not the default.

Day 7 · Idiomatic Rust

Cargo, tests, idioms. Where clippy lives.

  1. 18

    Cargo & crates

    One tool: build, test, doc, publish. crates.io is the registry.

  2. 19

    Testing & benchmarks

    #[test] inside the module. cargo test runs everything. doc tests too.

  3. 20

    Idiomatic Rust

    clippy is the style guide. iterator chains > loops. Avoid unsafe.