Rust
Modern Rust (1.98, edition 2024) from your first program to fast, safe, production services, with ownership taught as the core idea it is.
Free to read now, no account needed: Before you start: programs, compilers, and the command line. Create a free account to open the other chapters, take the quizzes and keep your progress.
My setup
Lessons that differ by operating system or tool show your choice first, and fold away notes meant for other setups. You can switch tabs in any lesson β it remembers what you pick.
Operating system
Editor
Database
1 Set up Rust π
Create a free account to open this chapter.
- rustup, toolchains, and components ~25 min
- Install Rust ~30 min
- Your first program ~30 min
- Your first Cargo project ~30 min
- Choosing an editor ~35 min
- Format, lint, and save your work ~30 min
2 How Rust code builds and runs π
Create a free account to open this chapter.
- From source code to a native executable ~30 min
- Crates, the standard library, and your first dependency ~35 min
- Releases, editions, and rust-version ~30 min
- Reading compiler errors and warnings ~35 min
- Targets, host, and pinned toolchains ~30 min
3 Values, types, and variables π
Create a free account to open this chapter.
- Variables and mutability ~35 min
- Constants, statics, and shadowing ~35 min
- Integers ~45 min
- Floats, bools, and chars ~40 min
- Tuples and arrays ~40 min
- Text: a first look ~30 min
- Conversions and casting ~45 min
- Parsing and formatting ~45 min
4 Expressions and control flow π
Create a free account to open this chapter.
- Statements and expressions ~35 min
- if as an expression ~35 min
- Loops ~40 min
- break, continue, and loop labels ~30 min
- match, a first look ~35 min
- Reading input ~40 min
5 Functions π
Create a free account to open this chapter.
- Defining and calling functions ~40 min
- Scope and blocks ~35 min
- The unit and never types ~35 min
- A first look at tests ~40 min
- Comments and doc comments ~30 min
6 Memory: the stack and the heap π
Create a free account to open this chapter.
- What memory is ~35 min
- The stack ~40 min
- The heap ~40 min
- A String in memory ~45 min
- Who frees memory ~40 min
- Drop at the end of scope ~40 min
7 Ownership π
Create a free account to open this chapter.
- The ownership rules ~40 min
- Moves ~45 min
- Copy types ~35 min
- Clone ~35 min
- Ownership and functions ~45 min
- Predicting moves ~50 min
8 Borrowing and references π
Create a free account to open this chapter.
- References ~40 min
- Mutable references ~40 min
- The borrowing rules ~45 min
- A borrow lasts until its last use ~35 min
- Dangling references ~40 min
- Slices ~45 min
- Fixing borrow errors ~50 min
9 Structs and methods π
Create a free account to open this chapter.
- Defining structs ~45 min
- Tuple and unit structs ~35 min
- Methods and self ~50 min
- Associated functions and constructors ~45 min
- Deriving common traits ~45 min
- Structs in memory ~40 min
10 Enums and pattern matching π
Create a free account to open this chapter.
- Enums and variants ~45 min
- Option ~45 min
- Result, a first look ~40 min
- match in depth ~60 min
- if let, let else and while let ~50 min
- Patterns everywhere ~40 min
- Modelling with enums ~55 min
11 Handling errors π
Create a free account to open this chapter.
- Panics ~40 min
- Result in practice ~40 min
- unwrap, expect, and when they are fine ~40 min
- The question mark operator ~45 min
- Errors from main ~35 min
- Panic or Result? ~40 min
12 Collections π
Create a free account to open this chapter.
- Vec ~40 min
- Iterating and ownership ~40 min
- VecDeque ~30 min
- HashMap ~45 min
- HashSet and set operations ~35 min
- BTreeMap and BTreeSet ~35 min
- BinaryHeap ~35 min
- Choosing a collection ~50 min
13 Strings, text, and Unicode π
Create a free account to open this chapter.
- UTF-8 and bytes ~40 min
- String and &str ~40 min
- Chars, scalar values, and graphemes ~45 min
- Slicing safely ~45 min
- Building and formatting text ~40 min
- Parsing text ~50 min
- Encoding and decoding ~45 min
14 Generics π
Create a free account to open this chapter.
- Why generics ~35 min
- Generic functions ~50 min
- Generic structs and enums ~45 min
- Generic impl blocks ~45 min
- Const generics ~45 min
- Monomorphization ~45 min
15 Traits π
Create a free account to open this chapter.
- Defining and implementing traits ~45 min
- Default methods ~35 min
- Trait bounds and where clauses ~45 min
- Standard library traits ~60 min
- Associated types and constants ~45 min
- Supertraits and generic traits ~45 min
- Operator overloading ~45 min
- Coherence and the orphan rule ~50 min
16 Trait objects and dispatch π
Create a free account to open this chapter.
- dyn Trait ~40 min
- Fat pointers and vtables ~40 min
- Static vs dynamic dispatch ~40 min
- impl Trait in return position ~40 min
- Dyn compatibility ~40 min
- Choosing generics, enums or trait objects ~40 min
17 Designing errors π
Create a free account to open this chapter.
- The Error trait ~40 min
- Custom error enums ~45 min
- Conversions with From ~45 min
- Box<dyn Error> revisited ~40 min
- Libraries versus applications ~50 min
- Reporting errors to humans ~45 min
18 Closures π
Create a free account to open this chapter.
- Closure syntax and inference ~35 min
- Capturing the environment ~40 min
- Move closures ~35 min
- Fn, FnMut and FnOnce ~40 min
- Storing and returning closures ~45 min
19 Iterators π
Create a free account to open this chapter.
- The Iterator trait ~45 min
- Adapters ~45 min
- Consumers ~45 min
- Collecting into collections ~45 min
- Writing your own iterator ~45 min
- Loops or iterators ~45 min
20 Lifetimes π
Create a free account to open this chapter.
- What a lifetime is ~40 min
- Annotating functions ~45 min
- Elision rules ~40 min
- References in structs ~50 min
- The 'static lifetime ~40 min
- Lifetime bounds ~45 min
- Common lifetime errors ~50 min
21 Modules and project structure π
Create a free account to open this chapter.
- Packages, crates, and modules ~40 min
- mod and files ~40 min
- Visibility ~45 min
- Paths and use ~45 min
- Re-exports and API shape ~40 min
- Splitting a binary for testability ~45 min
22 Cargo in depth π
Create a free account to open this chapter.
- Cargo.toml, table by table ~40 min
- Version numbers and how Cargo chooses ~45 min
- Cargo.lock and builds you can repeat ~40 min
- Features, optional parts of a crate ~45 min
- Profiles, dev and release ~40 min
- Workspaces, several packages built as one ~50 min
- Build scripts, extra binaries, examples and benchmarks ~50 min
- Auditing your dependencies ~40 min
23 Testing π
Create a free account to open this chapter.
- Unit tests and assertions ~45 min
- Integration tests ~40 min
- Documentation tests ~40 min
- Fixtures and organization ~40 min
- Parameterized and property-based tests ~45 min
- Mocking with traits ~40 min
- Fuzzing and test runners ~30 min
- Debugging a failing test ~40 min
24 Documentation, code quality, and API design π
Create a free account to open this chapter.
- Rustfmt and style ~40 min
- Clippy and lints ~45 min
- Rustdoc ~45 min
- Designing a public API ~50 min
- Semver for libraries ~45 min
- Publishing a crate ~45 min
25 Files and the filesystem π
Create a free account to open this chapter.
- Reading and writing files ~40 min
- Paths ~40 min
- Directories ~40 min
- Metadata and permissions ~40 min
- Errors and edge cases ~45 min
- Temporary and memory-mapped files ~40 min
26 Processes, environment, and I/O π
Create a free account to open this chapter.
- Command-line arguments and the environment ~45 min
- Standard streams ~50 min
- Running other programs ~50 min
- Pipes and child processes ~55 min
- Signals and shutdown ~45 min
- Where Rust meets the operating system ~45 min
27 Command-line applications π
Create a free account to open this chapter.
- Argument parsing with clap ~40 min
- Subcommands ~35 min
- Configuration ~40 min
- Logging ~40 min
- Colors and progress ~35 min
- Error reporting and exit codes ~45 min
28 Serialization and data formats π
Create a free account to open this chapter.
- The serde model ~40 min
- JSON ~45 min
- TOML and CSV ~45 min
- Attributes ~50 min
- Custom serialization and validation ~50 min
- Binary formats ~45 min
- Untrusted input ~50 min
29 Smart pointers π
Create a free account to open this chapter.
- Box ~40 min
- Deref and Drop ~45 min
- Rc and shared ownership ~40 min
- Cell and RefCell ~45 min
- Rc, RefCell and cycles ~45 min
- Choosing a pointer ~35 min
30 Threads and message passing π
Create a free account to open this chapter.
- Threads ~40 min
- Move closures and threads ~40 min
- Channels ~45 min
- Send and Sync ~45 min
- Parallel data processing ~45 min
31 Shared state and synchronization π
Create a free account to open this chapter.
- Arc and mutex ~45 min
- RwLock and Condvar ~45 min
- Atomics ~45 min
- Deadlocks and starvation ~45 min
- Lazy and global state ~40 min
- Choosing a strategy ~45 min
32 Async fundamentals π
Create a free account to open this chapter.
- Why async ~40 min
- Futures are lazy ~45 min
- Async and await ~45 min
- Runtimes and executors ~40 min
- Tasks ~45 min
- Concurrency versus parallelism ~45 min
- Async is not automatically faster ~40 min
33 Async in practice π
Create a free account to open this chapter.
- Async channels ~45 min
- Joining and selecting ~50 min
- Timeouts and cancellation ~50 min
- Blocking and locks in async ~45 min
- Async traits and closures ~50 min
- Pin in one section ~40 min
- Testing async code ~50 min
34 Networking π
Create a free account to open this chapter.
- IP addresses, ports, sockets and DNS ~45 min
- A TCP client and server ~60 min
- UDP ~45 min
- Async TCP with Tokio ~55 min
- HTTP: the protocol ~55 min
- HTTP clients with reqwest ~55 min
- TLS and HTTPS ~45 min
- WebSockets ~50 min
35 Web backends π
Create a free account to open this chapter.
- The landscape ~40 min
- Routing and handlers ~60 min
- Shared state ~50 min
- Middleware ~60 min
- Errors in handlers ~55 min
- Authentication and authorization concepts ~60 min
- Configuration and graceful shutdown ~55 min
- Testing a service ~60 min
36 Databases π
Create a free account to open this chapter.
- Relational databases and SQL ~50 min
- Connecting with sqlx ~45 min
- Queries and prepared statements ~55 min
- Transactions ~45 min
- Migrations ~45 min
- Compile-time checked queries ~45 min
- ORMs and query builders ~40 min
37 Unsafe Rust π
Create a free account to open this chapter.
- What unsafe means ~40 min
- Raw pointers ~40 min
- Undefined behavior ~45 min
- Unsafe functions and safety contracts ~45 min
- Safe abstractions over unsafe code ~50 min
- Unsafe traits, unions and mutable statics ~45 min
- Checking unsafe code ~45 min
38 Foreign function interface π
Create a free account to open this chapter.
- ABI and C-compatible types ~45 min
- Calling C from Rust ~50 min
- Exposing Rust to C ~50 min
- Build integration ~50 min
- Ownership across the boundary ~55 min
- Errors and panics across FFI ~55 min
39 Macros π
Create a free account to open this chapter.
- When a macro and when not ~45 min
- Declarative macros with macro_rules! ~75 min
- Procedural macros ~60 min
- Derive macros ~60 min
- Attribute and function-like macros ~55 min
- Debugging macros ~50 min
40 Advanced types and traits π
Create a free account to open this chapter.
- Dynamically sized types and Sized ~40 min
- PhantomData and marker types ~45 min
- Typestate ~45 min
- Generic associated types ~45 min
- Higher-ranked trait bounds ~40 min
- Variance ~45 min
- Type aliases, newtypes and sealed traits ~50 min
41 Performance π
Create a free account to open this chapter.
- Measure first ~50 min
- Profiling ~50 min
- Allocation ~55 min
- Memory layout and cache ~50 min
- Zero-cost abstractions and inlining ~45 min
- Memory analysis ~45 min
42 Rust beyond the desktop: embedded and WebAssembly π
Create a free account to open this chapter.
- no_std: Rust without an operating system ~50 min
- Microcontrollers and HALs ~50 min
- What WebAssembly is ~45 min
- From Rust to Wasm ~50 min
- JavaScript interop ~55 min
- Where Rust fits ~35 min
43 Idiomatic Rust π
Create a free account to open this chapter.
- Patterns you already know ~50 min
- Constructors and validation ~50 min
- Extension traits and sealed traits ~45 min
- Composition and dependency injection ~55 min
- Anti-patterns ~60 min
- Choosing a design ~50 min
44 Building, deploying, and CI π
Create a free account to open this chapter.
- Release builds and binary size ~40 min
- Cross-compilation ~40 min
- Static and dynamic linking ~35 min
- Containers ~45 min
- Shipping on each platform ~45 min
- CI pipelines ~50 min
45 Observability and security π
Create a free account to open this chapter.
- Structured logging and tracing ~55 min
- Metrics and distributed tracing ~50 min
- Error reporting and diagnostics ~50 min
- What Rust does and does not guarantee ~55 min
- Input validation and secrets ~60 min
- Supply chain security ~50 min
- Reviewing unsafe and dependencies ~45 min
46 Capstone: a production service π
Create a free account to open this chapter.
- Planning the service ~50 min
- Building the core library ~55 min
- The HTTP layer and database ~60 min
- Observability and configuration ~50 min
- Hardening and performance ~55 min
- Shipping it ~50 min
Appendices
Reference chapters on the tools the course uses. Dip in when a lab or a section sends you here; they are not part of the course exam.
A Appendix A: Old way, modern way π
Create a free account to open this chapter.
- Reading older Rust ~30 min
- Old syntax ~40 min
- Old crates and patterns ~40 min
- Migrating to edition 2024 ~40 min
B Appendix B: Features by version π
Create a free account to open this chapter.
- How features reach stable ~30 min
- Language features since 1.80 ~30 min
- Library and Cargo features since 1.80 ~30 min
C Appendix C: Rust for programmers from other languages π
Create a free account to open this chapter.
- Coming from C++ ~45 min
- Coming from C# and Java ~45 min
- Coming from Python and JavaScript ~45 min
- Coming from Go ~40 min
- The translation table ~35 min