Rustlings

The official rustlings curriculum, served as a freeCodeCamp-style workbench: editor on one side, instructions and hints on the other, a real Rust compiler one keystroke away. Compilation runs on play.rust-lang.org; your progress lives in your browser.

94 exercises · 25 chapters

Curriculum

00
Intro
Get used to the workbench. Print to the screen and run code.
01
Variables
let, mut, shadowing, and the difference between bindings.
02
Functions
Define and call functions. Argument and return types.
03
If
Branching with if, else if, and if as an expression.
04
Primitive Types
Booleans, integers, floats, chars, tuples, and arrays.
05
Vecs
Heap-allocated, growable arrays. Push, pop, and iterate.
06
Move Semantics
Ownership rules: move, borrow, and the borrow checker.
07
Structs
Group related data. Tuple, named, and unit structs.
08
Enums
Sum types with variants. Pattern-match exhaustively.
09
Strings
&str vs. String. Slicing, conversion, and ownership.
10
Modules
Organise code with mod, pub, and use.
11
Hashmaps
Key/value storage. Insert, lookup, and iteration.
12
Options
Encode absence with Option<T>. Unwrap safely.
13
Error Handling
Result, ?, and propagating recoverable errors.
14
Generics
Write code that works for any type.
15
Traits
Define shared behaviour and implement it across types.
16
Lifetimes
Annotations that make borrows provably safe.
17
Tests
#[test], assertions, and cargo test.
18
Standard Library Types
Standard library types and lazy iteration.
19
Smart Pointers
Box, Rc, RefCell. Heap ownership patterns.
20
Threads
Spawn threads, share data with Arc and Mutex.
21
Macros
macro_rules! and procedural macros.
22
Clippy
Idiomatic Rust through the official linter.
23
Type Conversions
From, Into, TryFrom, and explicit casts.
99
Quizzes
3 exercises.

Rustlings is MIT-licensed and maintained by the Rust community. This is a fan-made browser interface built with Monaco, shadcn/ui, and the public Rust Playground API.