Types
Checkpoints
- Algebraic Data Types Essential What an algebraic data type (ADT) is, why combining values (`AND`) and choosing between alternatives (`OR`) are the two building blocks every data model is made of, and why Rust's `struct` and `enum` together cover everything you can express with ADTs.
- Type Alignment Essential A type's *alignment* is the address boundary one of its values must start on, queryable with `std::mem::align_of`. You'll see why hardware imposes alignment, how the compiler inserts padding between struct fields to satisfy it, why reordering fields can shrink a struct, and the `#[repr(C)]` and `#[repr(packed)]` attributes that change the default layout.
- Primitive Types in Rust Essential Rust's built-in primitive types — fixed-width integers (`i8`…`i128`, `u8`…`u128`, `isize`, `usize`), floating-point numbers (`f32`, `f64`), `bool`, `char`, and the unit type `()` — and how they map onto the Zig primitives you already know.
- What a Type Is in Rust Essential An orientation to Rust's type system: what a type tells the compiler, why every value has exactly one statically-known type, the difference between primitive and user-defined types, and how this contrasts with the looser type discipline of Zig and the runtime types of dynamic languages.
- Generic Inductive Definitions Essential How to parametrise an inductive type by another type — `enum Option<T>`, `enum List<T>`, `struct Pair<A, B>`. You'll see the `<T>` type-parameter syntax, why a generic definition compiles once but produces a distinct concrete type per instantiation, and how this is the same idea as a polymorphic function applied to types.
- Inductive Types Essential An *inductive type* is a type defined by a finite list of constructors, where each constructor takes a known list of arguments. Sums and products are the smallest examples; this checkpoint introduces the general pattern, the connection to mathematical induction, and why values of an inductive type can be walked by structural recursion.
- Iterated (Recursive) Inductive Types Essential An iterated inductive type is one whose constructors may refer back to the type itself — the classic recursive definitions like singly-linked lists and binary trees. You'll see why Rust requires recursive variants to live behind an indirection (`Box<Self>` or similar) and how that mirrors the recursive definition's structure exactly.
- Product Types — Structs and Tuples Essential Rust's product types: tuples and `struct`s bundle several values into one. You'll see named-field structs, tuple structs, unit structs, the field-access and destructuring syntax, and why a product type's value count is the *product* of its fields' value counts.
- References as Types Essential Rust's reference types `&T` and `&mut T` are the direct analog of Zig's `*T`: a value that stores another value's address. This checkpoint introduces references purely as *types* — how to form them with `&`/`&mut`, how to read through them with `*`, and how they compare to raw pointers. The compile-time rules that govern when a reference is *valid* (the borrow checker) come later.
- Simultaneous (Mutually Recursive) Inductive Types Essential When two or more inductive types refer to each other in their definitions, they are *simultaneous* (mutually recursive) inductive types. You'll see classic examples — expression and statement, tree and forest — and how to declare and traverse them in Rust without tripping the recursion rules.
- The Size of a Type Essential Every Rust type a value can be stored in has a fixed compile-time size in bytes, queryable with `std::mem::size_of`. You'll see why primitive sizes match their bit width, how structs and enums compute their sizes, and which kinds of types (slices, trait objects) deliberately have *no* statically-known size.
- Slices Essential A slice `[T]` is a contiguous run of `T` values whose length is not known at compile time, almost always handled through a *slice reference* `&[T]` or `&mut [T]` — a fat pointer holding both an address and a length. You'll see how slices generalise references, why `&str` is just a slice of UTF-8 bytes, and how indexing and iteration work on them.
- Sum Types — Enums Essential Rust's sum types: `enum` declares a fixed list of *variants*, and a value of the enum is exactly one of them. You'll see C-style enums, enums whose variants carry payloads, why this models 'one of several possibilities' precisely, and why the value count is the *sum* of the variants' value counts.