Rust
Checkpoints
- Borrowing vs. Taking Ownership Essential When designing a function that uses a value, you can either *borrow* it (take a reference `&T` or `&mut T` and leave ownership with the caller) or *take* it (accept `T` by value and become its new owner). You'll see the trade-offs — who has to think about lifetimes, who pays the cost of `Drop`, when taking ownership is the right call — and learn the conventions Rust APIs follow.
- Functions in Rust Essential How to declare a function in Rust with `fn name(arg: T, …) -> Ret { … }`: parameter type annotations are mandatory, the return type defaults to `()`, the final expression of the body is the return value, and `return` is reserved for early exits. You'll see how Rust's `fn` differs from Zig's function syntax and how block-expression semantics let you write `let x = if cond { a } else { b };` without ceremony.
- Introduction to Rust Language Essential An introduction to Rust: why it exists, what problem its ownership system solves, and how the memory concepts from the Zig course map directly onto Rust's compile-time safety guarantees.
- Ownership Essential Ownership is Rust's compile-time mechanism for enforcing RAII automatically. Every value has exactly one owner; when the owner goes out of scope, the value is dropped. You'll see the three ownership rules, how assignment transfers ownership (so the source variable can no longer be used), and why the `Sized`, `Clone`, and `Copy` traits determine which kinds of values transfer this way and which are duplicated implicitly instead.
- Pattern Matching Essential Pattern matching is Rust's primary tool for inspecting algebraic data: a *pattern* simultaneously tests a value's shape and binds parts of it to new names. You'll see patterns in `let`, function parameters, `if let`, `while let`, and as the foundation that makes `match` expressive.
- Resource Acquisition Is Initialization (RAII) Essential RAII is the design pattern that ties a resource's lifetime to a value's lifetime: acquire the resource when the value is created, release it when the value is destroyed. You'll see why this turns 'remember to clean up' into 'let the compiler do it', how `Box`, `Vec`, and file handles all follow the same pattern through `Drop`, and why RAII is the right mental model for the ownership rules you're about to meet.
- Variables in Rust Essential How to declare variables in Rust with `let`, the role of `mut`, why bindings are immutable by default, shadowing, and how Rust's type inference fills in type annotations you omit.
- Visibility — `pub` and Friends Essential Rust organises code into *modules*, and every item (function, struct, field, trait) is private to its own module by default. You'll see the visibility modifiers — `pub`, `pub(crate)`, `pub(super)`, `pub(in path)` — what each one means, why struct fields have their own visibility independent of the struct itself, and how the privacy boundary lines up with module boundaries.