Memory safety without a garbage collector
Rust
Rust is a compiled systems language whose compiler enforces ownership and borrowing rules at build time, so whole classes of memory and data-race bugs are rejected before a program ever runs. It is used for command-line tools, network services, embedded firmware and WebAssembly. This curriculum starts with syntax, variables, types, control flow and functions; the intermediate lessons cover ownership, structs, enums and pattern matching, which is where Rust differs most from other languages; the advanced lessons put collections, iterators, Result and Option to work. Every example is compiled and run with rustc 1.94 (edition 2021), and every exercise is checked against real tests.
- lessons
- 5 lessons
- exercises
- 13 exercises
- interview questions
- 12 interview questions
What Rust is used for
- Systems programming
- WebAssembly
- Command-line tools
- Backends that need speed
How examples are checked
Every example and every exercise solution was run with rustc 1.94 at build time. In-browser execution for Rust is not available yet; the pages say so rather than pretending.
Learn
The Rust learning path
Read in order: each lesson leans only on the ones before it. Every lesson ends with a small program to write and links to matching exercises.
Practice
Practise Rust
13 exercises across 10 topics, each checked by running your program against test cases. Start with these:
- Boards to cover a panelEasy
Write a Rust function that returns how many boards of a given width cover a panel, rounding up. Practise function signatures, return values and rounding up.
FunctionsNot started
- Library late feeEasy
Compute a library's overdue fee with a two-day grace period and a cap, using if/else and min in Rust. An exercise in simple branching.
Control flowNot started
- Bakery order tallyMedium
Process add and remove commands for a bakery counter with slice patterns in match, then print the tally in alphabetical order. Practise Rust pattern matching.
Pattern matchingNot started
- Hyphenate product codesMedium
Insert a hyphen wherever a product code switches between letters and digits, for every code on input. Practise walking chars and tracking state in a Rust loop.
StringsNot started
More