Rust · Learn

The Rust curriculum

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
hours of reading
0.7 hours of reading
exercises to practise
13 exercises to practise

Beginner

5 lessons · about 40 minutes of reading, plus practice.

  1. Rust Syntax and Your First ProgramHow a Rust program is put together: fn main, statements and semicolons, println! formatting, comments, blocks, and reading one line of input.8 min
  2. Variables and Mutability in RustWhy Rust variables are immutable by default, when to write let mut, how shadowing with let creates a new variable, and how const differs from let.7 min
  3. Data Types in RustRust's scalar and compound types: integer and float sizes, bool, char, tuples and arrays, plus casting with as and parsing numbers from input text.9 min
  4. Control Flow in Rust: if, loop, while and forHow Rust branches and repeats: if as an expression, loop with break values, while, for over ranges and arrays, continue, and labelled breaks.9 min
  5. Functions in RustHow to define and call Rust functions: typed parameters, the -> return type, returning the last expression, early return, tuples, and &str arguments.8 min