Rust from the ground up
Fast code the compiler checks
- Beginner
- 12 chapters
- 194 min read
A hands-on introduction to Rust, from your first program to threads and shared state: ownership and borrowing explained in plain words, every idea run on a real compiler, and a short quiz at the end of each chapter.
What You'll Learn
- Write and run a Rust program, and read what the compiler tells you
- Use the everyday types, and say when a value may change
- Write functions, decisions and loops that return values
- Understand ownership: one owner, moves, and clones you chose
- Borrow with references and slices instead of giving values away
- Model data with structs, methods and enums — including Option
- Match on values and handle every case the compiler asks for
- Return results, use the question mark, and know when a panic is right
- Keep data in vectors and maps, and say it with iterator chains
- Describe behaviour with traits and reuse it through generics
- Split a program into modules and write tests beside the code
- Run work on threads, and share state safely with Arc and Mutex
Prerequisites
- No Rust at all — the course starts at the first program
- Any experience with one other language makes the first chapters quicker, but none is assumed
Course Content
- 01Your first Rust programNot started
What Rust is, what the compiler does for you, and the smallest complete program — one function, one line of output, and a run.
- 02Values, types and printingNot started
Variables that cannot be reassigned by accident, the handful of types you will actually use, and how to put values into text without guessing.
- 03Functions, decisions and loopsNot started
Functions that take values and give one back, if and match as expressions, and the three loops Rust gives you — including the one that returns a value.
- 04OwnershipNot started
The rule that everything else in Rust rests on: every value has one owner, moving it is not copying it, and the value is cleaned up when the owner goes out of scope.
- 05Borrowing and referencesNot started
Lending a value instead of giving it away: &T to read, &mut T to change, the one rule that keeps them safe, and slices — a view into part of a collection.
- 06Structs, methods and enumsNot started
Making your own types: a struct gathers fields, impl gathers the behaviour that goes with them, and an enum says a value is one of a fixed set of shapes.
- 07Pattern matchingNot started
match that checks every case, patterns that pull data apart while choosing, and the shorter if let and while let for when one case is all you care about.
- 08Errors you can recover fromNot started
Result instead of exceptions, unwrap and expect and when to avoid them, the question mark that passes errors up a level, and the line between a bug and a bad day.
- 09Vectors, maps and iteratorsNot started
The two collections you will reach for first — a growable list and a lookup by key — and the iterator chain that turns a loop into a sentence.
- 10Traits and genericsNot started
Describing behaviour instead of types — a trait is a promise a type can keep — and writing one function that works for every type that keeps it.
- 11Modules, crates and testsNot started
Splitting a program into files that can see only what they should, the cargo commands that hold a project together, and the tests that live beside the code they check.
- 12Threads and shared stateNot started
Running work at the same time, sending values between threads, and sharing one value safely with Arc and Mutex — the chapter where the ownership rules pay off.
