Rust

A systems language that checks ownership, types, and lifetimes before the program runs, so you get native speed without a garbage collector.

Lessons

The overview is what Rust is and why the compiler is strict. These pages take one folder each and walk every file in it as its own section.

  1. 01

    Getting Started

    What Rust is, how rustup and Cargo fit together, and how to read a small program before you write one.

  2. 02

    Data and Control

    Bindings, scalars, tuples, arrays, functions as expressions, and if, loop, and match as the control you actually write.

  3. 03

    Ownership and Borrowing

    One owner, moves versus copies, shared and mutable borrows, slices, and when Drop frees the value.

  4. 04

    Structs and Enums

    Structs with methods, Option and custom enums, match, method receivers, and newtypes that make bad states unrepresentable.

  5. 05

    Error Handling

    Result, the question mark, typed errors, and the line between a panic and a value you return to the caller.

  6. 06

    Collections

    Vec growth, HashMap and HashSet, String versus str, and Cow plus Path when ownership of text is optional.

  7. 07

    Modules and Packages

    Modules and visibility, use paths, Cargo features, and how a workspace splits one product into crates.

  8. 08

    Generics and Traits

    One function for many types, trait bounds, trait objects, the standard traits you read every day, and macros enough to follow them.

  9. 09

    Lifetimes

    Why a returned reference needs a named lifetime, elision, and the patterns that keep borrows shorter than the data they point at.

  10. 10

    Closures and Iterators

    Fn, FnMut, and FnOnce, then lazy iterator chains: filter, map, collect, windows, zip, and partition.

  11. 11

    Smart Pointers

    Box for a heap value, Rc and RefCell when one thread shares, and Arc with Mutex when many threads share.

  12. 12

    Concurrency

    Threads, Send and Sync, and channels that move a value from one thread to another instead of sharing it.

  13. 13

    Async and Await

    Futures stay lazy until a runtime polls them. Timeouts, cancellation, streams, and select are how that scales.

  14. 14

    Unsafe and FFI

    Unsafe is a checked promise at a small boundary. FFI crosses that boundary with repr(C), CString, and documented ownership.

  15. 15

    Testing

    Unit tests, integration tests, and doctests, plus fakes for time and collaborators so a test does not wait on the world.

  16. 16

    Production Patterns

    Crate layout, config and tracing, API errors with serde, clippy in CI, and a shutdown that finishes work already in flight.