Rust: From Basics to Expert
Four levels, twelve lessons, every example compiled with warnings as errors
Rust gives you the control of C and C++ without the two bugs that have caused most of the security problems in both: using memory after it has been freed, and two threads writing the same data at once. Not by checking at runtime, but by refusing to compile code where either is possible.
Overview
It is worth the climb where the alternative is C: operating systems, browsers, game engines, embedded work, and increasingly the performance-critical core of applications written in other languages. The payoff is a program that is as fast as the unsafe version and does not have the class of bug that made it unsafe.
Introduction
No Rust is assumed, but some programming experience helps: this is a language that asks you to be precise about things other languages decide for you. Expect Level 1 to be slower than the first level of any other course here - ownership is not difficult so much as unfamiliar, and everything after it depends on having it straight.
Three lessons and a Level Check quiz at each level, then an Expert Exam. There is no in-browser Rust runner on the site yet, so every example was compiled with warnings treated as errors and executed on a real toolchain before publication - install Rust with rustup from rust-lang.org and run each one with cargo run, or paste it into play.rust-lang.org.
Every example in this course was compiled with warnings treated as errors and executed on a real Rust toolchain before publication. There is no in-browser Rust runner yet, so the code blocks are for reading and for running in your own editor.
There is no in-browser runner for this language on the site, so to follow along install it with rustup from rust-lang.org and run each one with cargo run, or paste it into play.rust-lang.org.
By the end you will be able to read a compiler error and know what the borrow checker is actually objecting to, choose between Box, Rc and RefCell for a reason you can state, share data across threads without a data race being possible, and lay out a crate so that its public surface is the part you meant to publish.
What you will be able to do
- Explain what a move is, and why the old name stops compiling
- State the borrowing rule, and why it eliminates data races
- Model a domain with enums so a missing case will not compile
- Use ? and From so error handling disappears into the happy path
- Choose between Box, Rc, RefCell and Arc for a reason you can state
- Say what a lifetime annotation promises, and to whom
What each level covers
4 levels · 16 lessons
-
Level 1 - Basic
The rule the rest of the language is built on. Ownership and borrowing make data races and use-after-free compile errors rather than crashes, and this level is about making that rule second nature. Alongside it: exhaustive match, which will not let you forget a case, and iterators that do nothing at all until something asks them for a value.
4 lessons 46 min of reading
Start with Values, Types and Ownership → -
Level 2 - Intermediate
Rust's answers to the questions other languages answer with inheritance and exceptions. Structs and traits, with implementations kept separate from data; enums as real sum types, which is how Option replaces null; and error handling built on Result and the ? operator, where a function says in its signature how it can fail.
4 lessons 50 min of reading
Start with Structs, Traits and Implementations → -
Level 3 - Advanced
The parts that need the borrow checker explained rather than obeyed. Lifetimes, and what an annotation actually claims; Box, Rc and RefCell for when a single owner is not enough, and the cost of each; and fearless concurrency, where Send and Sync turn a data race into something that simply does not compile.
4 lessons 53 min of reading
Start with Lifetimes and the Borrow Checker → -
Level 4 - Expert
Memory and output, without a garbage collector anywhere. Where values live and when they are freed; why a debug build can be ten times slower than a release one, and what the optimiser is doing with that time; what unsafe actually enables and what it still does not; and how a crate is arranged, module by module.
4 lessons 58 min of reading
Start with Memory Without a Garbage Collector →
Guides and articles
Longer reading about this subject, written alongside the course.
Before you start
- No prior Rust
- Some experience of any programming language helps but is not required
Common questions
- What does the Rust: From Basics to Expert course cover?
- It is 4 levels and 16 lessons: Level 1 - Basic; Level 2 - Intermediate; Level 3 - Advanced; Level 4 - Expert. Each level ends with a quiz, and the last one is an exam over the whole course.
- How long does it take?
- About 207 minutes of reading and exercises - roughly 3.5 hours. It is self-paced with no cohort and no start date, so you can leave and come back and the site remembers where you were.
- What do I need to know first?
- No prior Rust. Some experience of any programming language helps but is not required.
- Is it free?
- Yes. Every lesson, example and quiz in this course is free to read, and you do not need an account to read them. Signing in only adds progress tracking and quiz results.
- What will I be able to do afterwards?
- Explain what a move is, and why the old name stops compiling. State the borrowing rule, and why it eliminates data races. Model a domain with enums so a missing case will not compile. Use ? and From so error handling disappears into the happy path. Choose between Box, Rc, RefCell and Arc for a reason you can state. Say what a lifetime annotation promises, and to whom.