Rust

A fast systems language that prevents memory bugs at compile time.

Rust is a systems programming language focused on safety, performance, and concurrency. Its compiler checks how memory is used, so whole classes of bugs are caught before your program runs.

  • Advanced
  • 12 lessons
Not started yet
Start lesson 1

Lessons

  1. Hello, World!Write and run your first Rust program, and learn how to print values with println! and create projects with Cargo.
  2. Variables & TypesLearn how to declare variables and which basic types Rust has. Variables cannot be changed unless you mark them as mutable, which makes code easier to reason about.
  3. Ownership & BorrowingLearn the ownership and borrowing rules that let Rust manage memory without a garbage collector. This is the most important new idea in Rust, so take it one step at a time.
  4. Structs & EnumsLearn how to model data with structs and enums, add methods with impl blocks, and handle each case with match. Rust uses these instead of classes.
  5. Error HandlingLearn how Rust handles errors with Result<T, E> and missing values with Option<T>. Because these are ordinary types, the compiler makes sure you deal with every failure case.
  6. Traits & GenericsLearn how traits describe shared behavior and how generics let one piece of code work with many types, without any runtime cost.
  7. Mini Project: CLI CalculatorBuild a command-line calculator that uses structs, enums, error handling and pattern matching together.
  8. Collections & IteratorsLearn the standard collections and how to process them with iterators. A chain of map, filter and sum compiles to code as fast as a hand-written loop.
  9. Generics & LifetimesLearn how generics let one function serve many types, and how lifetimes tell the compiler that a reference will not outlive the data it points to.
  10. Modules, Crates & CargoLearn how to split code into modules, use crates from crates.io, and manage builds, tests and dependencies with Cargo.
  11. Concurrency & Smart PointersLearn how to run code on multiple threads and share data safely with smart pointers. Rust's ownership rules turn data races into compile errors.
  12. Rust CheatsheetOwnership, pattern matching, and the types you use daily — one page.

Install it on your own computer

Install Rust with rustup, the official toolchain manager. It installs the compiler and Cargo, keeps them up to date, and can add other build targets later.

Bash
# Download and run rustup-init.exe from:
# https://www.rust-lang.org/tools/install

# Or via winget:
winget install Rustlang.Rustup

# After installation, restart your terminal:
rustup update stable
rustc --version
cargo --version

What people build with Rust

Learn the basics first, then pick up these tools when a project needs them.

Practical uses

  • Write memory-safe systems software
  • Build high-performance services and CLIs
  • Create embedded and WebAssembly applications
  • Develop engines, runtimes, and developer tools

Projects to try

  1. Fast grep clone
  2. Multithreaded web server
  3. WebAssembly image filter
  4. Embedded sensor logger

Common tools and packages

TokioAxumSerdeClapRayonSQLxCargoCriterion

Well-known software

Firefox componentsripgrepAlacrittyDenouvZed