Rust’s defining bet is that memory safety and data-race freedom can be checked at compile time, with no garbage collector and no runtime cost, by making ownership part of the type system. That single decision ripples through every concern below: it is why Rust needs an unsafe keyword, why its foreign-function boundary is where the guarantees stop, and why its answer to “who frees the memory” is different in kind from every other language here.
Rust is also this section’s monomorphization pole, and the only language here where the generic system carries the safety proof as well as the abstraction. A lifetime is declared in the same angle brackets as a type parameter, which means the borrow checker and the trait solver are working on one system rather than two. The price is paid in compiled output and compile time, and the folder is honest about it. The comparison against erasure, reification, and stenciling lives in Generics, Monomorphization vs Erasure.
The ownership system
The foundation. Everything else in the folder assumes these six.
- Ownership and Moves - the three rules, move semantics,
Copy, and the specified drop order at scope exit - Borrowing and Lifetimes - shared versus mutable borrows, the aliasing rule as both safety and optimization, and what elision does
- The Borrow Checker: NLL and Polonius - what the checker actually computes, and what a datalog reformulation is meant to buy
- Drop Order and RAII in Rust - where destructors run, what suppresses them, and the leak the language declines to forbid
- Smart Pointers: Box, Rc, and RefCell - the cases single compile-time ownership cannot express
- Interior Mutability and the Cell Family -
Cell,RefCell,OnceCell, and the one primitive the compiler treats as a special case
Traits and the generic vocabulary
A bound is the starting point, not the whole language. These notes go past T: Trait in the order the vocabulary was actually built.
- Traits and Generic Bounds - bounds as a compile-time contract, and the static versus dynamic dispatch choice
- Associated Types vs Type Parameters - an input to impl selection against an output of it, which is why
Iteratorcarries anItem - Lifetimes as Generic Parameters - the only thing in Rust that produces subtyping, declared in the same brackets as
T - Const Generics - parameterizing by a value rather than a type, and the macro-generated impls it retired
- Generic Associated Types - an associated type that takes its own parameters, and six and a half years of getting there
- Higher-Ranked Trait Bounds - what
for<'a>quantifies over, and the closure that cannot be typed without it - impl Trait in Argument and Return Position - one keyword with two opposite meanings, and a hidden type that leaks its auto traits
What monomorphization costs
The pole, priced.
- Monomorphization and Code Bloat - one machine-code copy per instantiation, billed as binary size and cache pressure
- Generic Code and Compile Times - what the compiler redoes per instantiation, and which levers actually reduce the work
- Trait Objects, Vtables, and Fat Pointers - the runtime-dispatch alternative, and every dyn-compatibility rule falling out of what fits in the table
Coherence and the limits
What the system refuses, and why the refusals are load-bearing.
- The Orphan Rule and the Newtype Pattern - a global property enforced by a local, conservative check
- Auto Traits and Negative Reasoning - the only place the compiler treats a missing impl as a fact
- Specialization and Why It Is Still Unstable - three innocent crates composing into a dispatch that depends on lifetimes
Values, patterns, and failure
- Pattern Matching and Enums - exhaustiveness as a compile error, refutability, and the binding modes that insert
reffor you - Error Handling: Result, Option, and ? - failure in the return type, and what
?desugars to - Panic, Unwinding, and Abort - a build-time choice, and the precise sense in which a panic is not an exception
- Slices, Vec, and Capacity - a pointer and a length, three fields, and a capacity number you can trust
- String vs str, and the UTF-8 Invariant - two string types for the same reason there are two sequence types, and the question indexing cannot answer
Abstraction without cost
- Iterators and Adapters - one required method, lazy adapters, and the benchmark behind the zero-cost claim
- Closures: Fn, FnMut, and FnOnce - the three call traits, the four capture modes, and why
movedoes not pick the trait
Macros, crates, and the build
- Macros: Declarative and Procedural - mixed-site hygiene, token-stream plugins, and when a generic was the better tool
- Cargo, Crates, and the Module Tree - the crate as the compiler’s unit of work, and why feature unification forces features to be additive
Concurrency and the unsafe boundary
- Send, Sync, and Fearless Concurrency - two marker traits, auto-derived through composition, and the data race they exclude
- Async Rust, Futures, and Pinning - an inert state machine you poll, and why
Pinexists at all - Unsafe Rust and Its Contract - the five superpowers, proof obligations created and discharged, and what Miri proves
- FFI and the C ABI in Rust - the exact point where the compiler stops proving and starts trusting your declaration
Read from the comparative layer
The cross-cutting substance lives in the common notes, read from Rust’s angle:
- Who Frees the Memory - ownership, borrowing, and
Rc/Arcas Rust’s answer - The C ABI and Foreign Function Interfaces -
extern "C",#[repr(C)], and crossing out of safe Rust - Undefined Behavior as a Contract - what
unsafeactually permits, and the invariants you must uphold - Serialization and Wire Formats - serde and the derive-macro approach to encoding
Any pages placed under this folder are auto-listed below by Quartz. See also the Programming Language Concepts theory this builds on.