Lumenary CS · Programming languages
Rust
A systems language that gives you the speed and control of C with memory safety checked by the compiler, from a first program to professional practice.
Rust is a compiled systems programming language that reached version 1.0 in 2015. It produces fast native programs with no garbage collector, and its compiler checks rules about ownership and borrowing that rule out whole families of bugs (use-after-free, data races, null dereferences) before a program ever runs. It is used for command-line tools, web services and cloud infrastructure, browsers, operating-system components, embedded devices and WebAssembly.
This course is for anyone who already knows what a variable, a loop and a function are: the Start level of Lumenary CS or equivalent experience in any language. It starts with installing Rust and printing a first line, works through the core language and the ownership model that makes Rust different, and ends with error handling, testing, concurrency, the tools professionals use every day, and a complete small project written in idiomatic style.
To run the code, install Rust with the official installer, rustup, from rust-lang.org/tools/install; it gives you the compiler, Cargo and the standard library. Or try any program in the browser at the Rust Playground. Every complete program in these lessons was compiled with the 2024 edition and run by Lumenary's test suite, and the output shown is the output it printed. The lessons were drafted with AI assistance and are awaiting review by a human computer scientist.
- Chloe · The Designer
“Why is the language built this way?” - Margaret · The Profiler
“What does it print, and what does it cost?” - Gideon · The Language Lawyer
“What exactly does the language guarantee?”
Foundations · 4 lessons
Foundations
Install Rust, write and run programs with Cargo, and learn the core language: values and types, control flow and pattern matching, and the ownership and borrowing rules at the heart of Rust.
- 1Getting started with RustWhere Rust came from, what it promises, and your first programs with rustup and Cargo. 45 min
- 2Values, mutability and typesVariables that don't change unless you say so, numbers whose size you choose, and blocks that have values. 50 min
- 3Control flow and pattern matchingBranches and loops that produce values, and match, the construct Rust programmers reach for first. 50 min
- 4Ownership, borrowing and lifetimesThe three rules that let Rust free memory without a garbage collector, and how to work with the borrow checker instead of against it. 60 min
Practice · 3 lessons
Practice
Model data with structs and enums, abstract with traits and generics, and do everyday work with collections, iterators and closures.
- 5Structs, enums, Option and ResultModelling your data so that the compiler knows its shape, including the shape of "nothing" and of "it went wrong". 55 min
- 6Traits and genericsShared behaviour without inheritance, code that works for many types at no run-time cost, and dynamic dispatch when you need it. 60 min
- 7Collections, iterators and closuresVectors, strings, maps and sets, and the iterator pipelines and closures that make everyday Rust short, fast and clear. 60 min
Professional · 3 lessons
Professional
Handle errors and write tests the way Rust teams do, share data safely across threads, know what unsafe code is for, and build a complete project with the everyday tools of the ecosystem.
- 8Error handling and testingPanics for bugs, Result for everything else, the ? operator, error types people can act on, and the tests that keep it all honest. 60 min
- 9Smart pointers, concurrency and unsafeBox, Rc, RefCell and Arc; threads, channels and locks without data races; async in outline; and what unsafe code is for. 65 min
- 10Tooling, ecosystem and a complete projectCargo, crates.io, rustfmt and Clippy as professionals use them, and a small program built from everything in the course. 70 min
Further reading and resources
- The Rust Programming Language websiteThe official home of Rust: installation, learning resources, governance and community.
- The Rust Programming Language ("the book") · Steve Klabnik, Carol Nichols, Chris Krycho and the Rust communityThe official, free book. The standard first read after (or alongside) this course.
- The Rust ReferenceThe closest thing Rust has to a language specification: precise descriptions of syntax and semantics.
- The Rust Standard Library documentationEvery type and function in std, with examples. Professionals keep it open all day.
- Rust by ExampleShort runnable examples of each language feature.
- The Cargo BookRust's build tool and package manager, in depth.
- Rust PlaygroundCompile and run Rust in the browser, with the stable, beta and nightly compilers.