CodeBlanks Logo Icon CodeBlanks
Free 4 levels

Rust

Learn safe and fast systems programming with Rust's unique ownership model. Memory safety, concurrency and zero-cost abstractions.

The Rust course covers ownership, borrowing, traits, generics, async and unsafe from the ground up. Build real projects and challenges to grow step by step from beginner to expert.

  • 357 lessons
  • 26 h 37 min
  • 7 projects

No account needed, you can start right away. To save your progress, create a free account

Levels

The Rust course goes from zero to expert in four levels. Start at any level you like.
Not sure of your level? Take the placement test
Beginner

Learn Rust fundamentals: variables, data types, functions, control flow, ownership, borrowing, structs, enums, match and error handling.

  • Rust basics
  • Variables
  • Data types
  • Strings
115 lessons · 8 h 38 min See lessons →
Intermediate

Deepen your Rust with traits, generics, lifetimes, smart pointers, closures, iterators, collections, modules, testing, file I/O, clap and serde.

  • Traits
  • Generics
  • Lifetimes
  • Trait bounds
115 lessons · 8 h 38 min See lessons →
Advanced

Master async/await, tokio, concurrency, channels, unsafe, FFI, macros, trait objects, GATs and const generics.

  • async/await
  • Tokio
  • Concurrency
  • Channels
81 lessons · 5 h 58 min See lessons →
Expert

Reach Rust mastery with compiler internals, memory layout, zero-cost abstraction, SIMD, inline assembly, no_std, embedded and build tools.

  • Compiler internals
  • Memory layout
  • Zero-cost abstraction
  • SIMD
46 lessons · 3 h 23 min See lessons →

Projects you will build

At every level you combine what you learned into a real page.

How does it work?

Short explanation

Each lesson explains one concept in a few short cards; no long videos or walls of text.

Try it right away

Multiple choice, fill-in-the-blank and matching exercises lock in what you just learned.

Write it yourself

You write real code in the in-browser editor; it is checked instantly and you see the result live.

Curriculum

62 groups · 357 lessons · 26 h 37 min

Learn Rust fundamentals: variables, data types, functions, control flow, ownership, borrowing, structs, enums, match and error handling.

1
Rust basics
6 lessons · 25 min
  1. 1 What is Rust? Learn that Rust is a safe, fast and concurrent systems language. 4 min
  2. 2 Project with Cargo Learn to set up a project with cargo new, Cargo.toml and the target folder. 4 min
  3. 3 Your first program Write your first Rust program with fn main and println!. 4 min
  4. 4 println! and formatting Print variables with the println! macro and the {} placeholder. 4 min
  5. 5 Comments Document your code with // and /* */ comments. 4 min
  6. 6 Summary - Rust basics Combine fn main, println! and comments to write your first program. 5 min
2
Variables
6 lessons · 25 min
  1. 1 Variables with let Define variables with the let keyword. 4 min
  2. 2 Mutability with mut Update variables with the mut keyword. 4 min
  3. 3 Constants with const Define compile-time constants with const. 4 min
  4. 4 Static variables Define static-lifetime variables with static. 4 min
  5. 5 Shadowing Reuse a name by shadowing the previous binding. 4 min
  6. 6 Summary - Variables Combine let, mut, const and shadowing to build a counter program. 5 min
3
Data types
6 lessons · 25 min
  1. 1 Integers Learn signed and unsigned integer types like i32 and u64. 4 min
  2. 2 Floating point Learn the f32 and f64 floating-point types. 4 min
  3. 3 Bool and char Store logic and characters with bool and char types. 4 min
  4. 4 Tuple Group different types in a single value with a tuple. 4 min
  5. 5 Array Learn fixed-size arrays of type [T; n]. 4 min
  6. 6 Summary - Data types Combine different types to build a grade-calculating program. 5 min
4
Strings
6 lessons · 25 min
  1. 1 &str vs String Learn the difference and use cases of &str and String. 4 min
  2. 2 Creating a String Learn String::new, String::from and to_string constructors. 4 min
  3. 3 Concatenating strings Concatenate strings with push_str and the + operator. 4 min
  4. 4 format! macro Build a new String with the format! macro. 4 min
  5. 5 String length Inspect a string with len, is_empty and chars methods. 4 min
  6. 6 Summary - Strings Combine String and &str to build a greeting message. 5 min
5
Project: CalculatorProject
5 lessons · 30 min
  1. 1 Project skeleton Set up the calculator project skeleton with main and println!. 6 min
  2. 2 Reading input Read number input from the user with std::io::stdin. 6 min
  3. 3 Computing Compute the result with trim, parse and arithmetic operations. 6 min
  4. 4 Error handling Handle parse errors with Result and warn the user. 6 min
  5. 5 Loop and exit Keep calculating with loop, break and a quit command. 6 min
6
Functions
6 lessons · 25 min
  1. 1 Defining with fn Define functions with the fn keyword. 4 min
  2. 2 Parameters Learn function parameters and their types. 4 min
  3. 3 Return value Specify the return type with the -> arrow. 4 min
  4. 4 Expressions and statements Learn the difference between expressions and statements. 4 min
  5. 5 Early return Return early with the return keyword. 4 min
  6. 6 Summary - Functions Combine parameters, returns and expressions to build calculation functions. 5 min
7
Control flow
6 lessons · 25 min
  1. 1 if-else Branch with if, else if and else. 4 min
  2. 2 match basics Match a value against patterns with match. 4 min
  3. 3 loop Loop forever with loop and exit with break. 4 min
  4. 4 while loop Loop while a condition holds with while. 4 min
  5. 5 for loop Iterate over an iterator with for. 4 min
  6. 6 Summary - Control flow Combine if, match and loops to build a number guessing game. 5 min
8
Ownership
6 lessons · 25 min
  1. 1 What is ownership? Learn what the ownership rules do for you. 4 min
  2. 2 Move semantics See how ownership transfers through moves. 4 min
  3. 3 Copy trait Learn how Copy types are duplicated instead of moved. 4 min
  4. 4 Functions and ownership See how passing a value into a function affects ownership. 4 min
  5. 5 Return and ownership See how returning a value transfers ownership back. 4 min
  6. 6 Summary - Ownership Combine move, Copy and function calls to trace ownership flow. 5 min
9
Borrowing
6 lessons · 25 min
  1. 1 References Create references with the & operator. 4 min
  2. 2 Mutable reference Take a mutable reference with &mut. 4 min
  3. 3 Borrowing rules Learn the rules for multiple references at the same time. 4 min
  4. 4 Dangling reference See how Rust prevents dangling references. 4 min
  5. 5 References and functions Pass references into functions and return them. 4 min
  6. 6 Summary - Borrowing Write a function that increments a counter via & and &mut references. 5 min
10
Slices
6 lessons · 25 min
  1. 1 String slices Reference part of a string with &str slices. 4 min
  2. 2 Slice syntax Learn the [a..b] and [a..] slice syntax. 4 min
  3. 3 Array slices Slice part of an array or vector with &[T]. 4 min
  4. 4 Slices and functions Pass slices to functions to borrow data. 4 min
  5. 5 Range types Learn the Range and RangeInclusive types. 4 min
  6. 6 Summary - Slices Combine string and array slices to write a first-word function. 5 min
11
Project: Guessing gameProject
5 lessons · 30 min
  1. 1 Game skeleton Set up the guessing game welcome screen with main and println!. 6 min
  2. 2 Reading input Read the user's guess with std::io::stdin. 6 min
  3. 3 Comparing numbers Parse the guess into a number and compare with Ordering. 6 min
  4. 4 Random number Generate a secret number with the rand crate. 6 min
  5. 5 Loop and exit End the game on a correct guess with loop and break. 6 min
12
Structs
6 lessons · 25 min
  1. 1 Struct definition Define a fielded struct with struct. 4 min
  2. 2 Creating an instance Create a struct instance and access its fields. 4 min
  3. 3 Tuple struct Learn the tuple struct type and when to use it. 4 min
  4. 4 Unit-like struct Get to know the fieldless unit-like struct. 4 min
  5. 5 Field update Move fields from one struct to another with the .. syntax. 4 min
  6. 6 Summary - Structs Combine fields and instantiation to build a point struct. 5 min
13
Methods
6 lessons · 25 min
  1. 1 impl block Define methods on a struct with impl. 4 min
  2. 2 self parameter Call methods through &self and access fields. 4 min
  3. 3 &mut self Define methods that mutate the struct with &mut self. 4 min
  4. 4 Associated functions Build constructors with associated functions that take no self. 4 min
  5. 5 Multiple impl blocks Write multiple impl blocks for a single struct. 4 min
  6. 6 Summary - Methods Combine impl, &self and &mut self to compute a Rectangle's area. 5 min
14
Enums
6 lessons · 25 min
  1. 1 Enum definition Define enumerations with enum. 4 min
  2. 2 Variants Construct and use enum variants. 4 min
  3. 3 Variants with data Define enum variants that carry data. 4 min
  4. 4 Option<T> Learn the Option<T> type and its Some/None variants. 4 min
  5. 5 Option instead of null Learn the advantages of Option over null. 4 min
  6. 6 Summary - Enums Combine data-carrying enums and Option to model an IP address type. 5 min
15
Pattern matching
6 lessons · 25 min
  1. 1 match patterns Match against different patterns with match. 4 min
  2. 2 Value binding Bind matched values with pattern variables. 4 min
  3. 3 if let Match a single pattern concisely with if let. 4 min
  4. 4 while let Loop while a pattern matches with while let. 4 min
  5. 5 _ wildcard Catch all remaining cases in one arm with _. 4 min
  6. 6 Summary - Pattern matching Combine match, if let and the _ wildcard to build a command interpreter. 5 min
16
Project: To-do CLIProject
5 lessons · 30 min
  1. 1 Task model Define the Todo struct and its fields. 6 min
  2. 2 Adding Write a function that appends a new task to Vec<Todo>. 6 min
  3. 3 Listing Print tasks with a for loop. 6 min
  4. 4 Marking done Mark a task done by index. 6 min
  5. 5 Reading commands Read command-line arguments with std::env::args. 6 min
17
Vectors
6 lessons · 25 min
  1. 1 Vec<T> Create dynamic arrays with Vec<T>. 4 min
  2. 2 Push and pop Add and remove elements with push and pop. 4 min
  3. 3 Index and get Access vector elements safely with index and get. 4 min
  4. 4 Looping a vector Iterate vector elements with for. 4 min
  5. 5 with_capacity Reserve capacity up front with with_capacity for better performance. 4 min
  6. 6 Summary - Vectors Combine push, get and for to build a shopping cart. 5 min
18
Advanced strings
6 lessons · 25 min
  1. 1 String and &str conversion Learn conversion methods between String and &str. 4 min
  2. 2 chars and bytes Split a string into chars or bytes iterators. 4 min
  3. 3 Slicing strings Learn the correct way to slice a substring. 4 min
  4. 4 contains and replace Search with contains and replace with replace. 4 min
  5. 5 split and join Split with split and join with join. 4 min
  6. 6 Summary - Advanced strings Combine split, contains and replace to build a text filter. 5 min
19
Error handling
6 lessons · 25 min
  1. 1 Result<T, E> Learn the Result<T, E> type and its Ok/Err variants. 4 min
  2. 2 panic! Learn unrecoverable errors with panic!. 4 min
  3. 3 ? operator Propagate errors automatically to the caller with ?. 4 min
  4. 4 match and Result Handle both arms of a Result with match. 4 min
  5. 5 unwrap and expect Learn the unwrap and expect shortcuts and their risks. 4 min
  6. 6 Summary - Error handling Combine Result, ? and match to build a number-reading function. 5 min
20
Beginner finalFinal
4 lessons · 28 min
  1. 1 Vowel counter Write a program that counts vowels in a string. 7 min
  2. 2 Average calculator Write and test a function that computes the average of a Vec. 7 min
  3. 3 Bank account Model a simple bank with an Account struct and methods. 7 min
  4. 4 Temperature converter Build a CLI that converts between Celsius and Fahrenheit. 7 min

Deepen your Rust with traits, generics, lifetimes, smart pointers, closures, iterators, collections, modules, testing, file I/O, clap and serde.

1
Traits
6 lessons · 25 min
  1. 1 What is a trait? Define shared behavior with traits. 4 min
  2. 2 Implementing a trait Implement a trait with impl Trait for Type. 4 min
  3. 3 Default methods Define default methods in a trait. 4 min
  4. 4 Traits as parameters Use traits as function parameters. 4 min
  5. 5 Multiple traits Implement multiple traits for one type. 4 min
  6. 6 Summary - Traits Combine trait and impl to write a Summary trait. 5 min
2
Generics
6 lessons · 25 min
  1. 1 Generic function Write generic functions with <T>. 4 min
  2. 2 Generic struct Define and use generic structs. 4 min
  3. 3 Generic method Write an impl block and methods for a generic struct. 4 min
  4. 4 Generic enum Define generic enums like Option<T>. 4 min
  5. 5 Turbofish Help type inference with the ::<> turbofish. 4 min
  6. 6 Summary - Generics Combine generic struct, method and enum to build Pair<T>. 5 min
3
Lifetimes
6 lessons · 25 min
  1. 1 What is a lifetime? Learn what lifetimes do for references. 4 min
  2. 2 Explicit lifetimes Specify explicit lifetime parameters with <'a>. 4 min
  3. 3 Function lifetimes Use lifetimes in function signatures. 4 min
  4. 4 Struct lifetimes Use lifetime parameters in structs that hold references. 4 min
  5. 5 Elision rules Learn the lifetime elision rules. 4 min
  6. 6 Summary - Lifetimes Write a function that returns the longest text using lifetime parameters. 5 min
4
Trait bounds
6 lessons · 25 min
  1. 1 Trait bound Constrain a generic parameter with <T: Trait>. 4 min
  2. 2 Multiple bounds Combine multiple trait bounds with +. 4 min
  3. 3 where clause Write long trait bounds readably with where. 4 min
  4. 4 impl Trait Specify parameter and return types with impl Trait. 4 min
  5. 5 dyn Trait Learn the dyn Trait trait object for dynamic dispatch. 4 min
  6. 6 Summary - Trait bounds Combine trait bounds and where to write a generic max function. 5 min
5
Project: Library crateProject
5 lessons · 30 min
  1. 1 Crate skeleton Set up a library crate with lib.rs. 6 min
  2. 2 Public API Expose an API with pub. 6 min
  3. 3 Generic structure Make the book model generic. 6 min
  4. 4 Searching with traits Add search with a Searchable trait. 6 min
  5. 5 Test infrastructure Add integration tests with the tests/ folder. 6 min
6
Smart pointers
6 lessons · 25 min
  1. 1 Box<T> Allocate on the heap with Box<T>. 4 min
  2. 2 Rc<T> Learn shared ownership with Rc<T>. 4 min
  3. 3 Arc<T> Learn thread-safe shared ownership with Arc<T>. 4 min
  4. 4 Box and recursion Define recursive types with Box. 4 min
  5. 5 Deref Learn automatic reference resolution with the Deref trait. 4 min
  6. 6 Summary - Smart pointers Combine Box and Rc to build a tree data structure. 5 min
7
Interior mutability
6 lessons · 25 min
  1. 1 RefCell<T> Learn runtime borrowing with RefCell<T>. 4 min
  2. 2 borrow and borrow_mut Use RefCell's borrow and borrow_mut methods. 4 min
  3. 3 Rc<RefCell<T>> Combine Rc and RefCell for mutable data with multiple owners. 4 min
  4. 4 Cell<T> Learn interior mutability for Copy types with Cell<T>. 4 min
  5. 5 External mutation Mutate inner data inside an immutable structure. 4 min
  6. 6 Summary - Interior mutability Build a graph edge list with Rc<RefCell<T>>. 5 min
8
Closures
6 lessons · 25 min
  1. 1 Closure syntax Define closures with the |param| body syntax. 4 min
  2. 2 Type inference Learn type inference in closures and when explicit types are required. 4 min
  3. 3 Capturing Learn how closures capture environment variables. 4 min
  4. 4 Fn, FnMut, FnOnce Tell apart the three closure traits Fn, FnMut and FnOnce. 4 min
  5. 5 Closure and iterator Use closures with iterator methods. 4 min
  6. 6 Summary - Closures Combine closures and move to build a counter-generating function. 5 min
9
Iterators
6 lessons · 25 min
  1. 1 Iterator trait Build your own iterator by implementing the Iterator trait. 4 min
  2. 2 next method Drain elements one by one with next. 4 min
  3. 3 map and filter Transform iterators with the map and filter adaptors. 4 min
  4. 4 collect Turn an iterator into a collection with collect. 4 min
  5. 5 Lazy evaluation Learn the lazy nature of iterators. 4 min
  6. 6 Summary - Iterators Combine map, filter and collect to build a word filter. 5 min
10
Collections
6 lessons · 25 min
  1. 1 HashMap Learn HashMap<K, V> and storing key-value pairs. 4 min
  2. 2 BTreeMap Use an ordered-key map with BTreeMap. 4 min
  3. 3 HashSet Build a set of unique elements with HashSet. 4 min
  4. 4 Entry API Insert into a map safely with the Entry API. 4 min
  5. 5 Iterating collections Learn iteration patterns over HashMap and Vec. 4 min
  6. 6 Summary - Collections Combine HashMap and the Entry API to build a word counter. 5 min
11
Project: CLI appProject
5 lessons · 30 min
  1. 1 Command skeleton Set up basic command reading with args. 6 min
  2. 2 State with Vec Hold application state with a Vec. 6 min
  3. 3 Result and commands Split commands into functions that return Result. 6 min
  4. 4 Processing with iterators Chain commands with iterators. 6 min
  5. 5 Error and exit Return a proper exit code on error. 6 min
12
Advanced error handling
6 lessons · 25 min
  1. 1 Error trait Define your own error by implementing std::error::Error. 4 min
  2. 2 thiserror Build derived error types with the thiserror crate. 4 min
  3. 3 anyhow Do flexible error handling with the anyhow crate. 4 min
  4. 4 Error conversion Convert between error types with the From trait. 4 min
  5. 5 Adding context Add context to errors with anyhow::Context. 4 min
  6. 6 Summary - Advanced error handling Combine thiserror and From to build a config reader error. 5 min
13
Modules
6 lessons · 25 min
  1. 1 Defining modules Define modules with mod. 4 min
  2. 2 use Bring module names into scope with use. 4 min
  3. 3 pub Control visibility with pub. 4 min
  4. 4 File modules Learn the file-based module hierarchy. 4 min
  5. 5 crate and super Reach from the crate root or parent module with crate and super. 4 min
  6. 6 Summary - Modules Combine mod, use and pub to set up a multi-file crate. 5 min
14
Crates and packages
6 lessons · 25 min
  1. 1 Binary and library crate Learn the difference between binary and library crates. 4 min
  2. 2 Cargo.toml Add dependencies with Cargo.toml. 4 min
  3. 3 Versions Learn semver version specifiers and the cargo update command. 4 min
  4. 4 Features Do conditional compilation with Cargo features. 4 min
  5. 5 Workspace Manage multiple crates under one workspace. 4 min
  6. 6 Summary - Crates and packages Combine a binary + library crate and a workspace to build a monorepo. 5 min
15
Testing
6 lessons · 25 min
  1. 1 Unit test Write unit tests with #[test]. 4 min
  2. 2 assert! macro Assert with assert!, assert_eq! and assert_ne!. 4 min
  3. 3 Integration test Write integration tests with the tests/ folder. 4 min
  4. 4 Doc test Write doc tests with ///. 4 min
  5. 5 should_panic Write tests that expect a panic with should_panic. 4 min
  6. 6 Summary - Testing Combine unit, integration and doc tests to test a math crate. 5 min
16
File I/O
6 lessons · 25 min
  1. 1 Reading a file Read a file with std::fs::read_to_string. 4 min
  2. 2 Writing a file Write a file with std::fs::write. 4 min
  3. 3 Append mode Learn append mode with OpenOptions. 4 min
  4. 4 BufReader Read line by line efficiently with BufReader. 4 min
  5. 5 Directory operations List directory contents with read_dir. 4 min
  6. 6 Summary - File I/O Combine read_to_string and write to build a log file processor. 5 min
17
CLI with clap
6 lessons · 25 min
  1. 1 Introducing clap Learn CLI basics with the clap crate. 4 min
  2. 2 Derive macro Define an argument struct with #[derive(Parser)]. 4 min
  3. 3 Positional argument Define positional arguments. 4 min
  4. 4 Option flag Define options and bool flags with --flag. 4 min
  5. 5 Subcommand Build a subcommand structure. 4 min
  6. 6 Summary - CLI with clap Combine derive, flag and subcommand to build a file CLI. 5 min
18
Serialization with serde
6 lessons · 25 min
  1. 1 Serialize and Deserialize Learn serde's core Serialize and Deserialize traits. 4 min
  2. 2 derive Auto-implement with #[derive(Serialize, Deserialize)]. 4 min
  3. 3 JSON Read and write JSON with serde_json. 4 min
  4. 4 Field rename Rename fields with #[serde(rename)]. 4 min
  5. 5 Option and default Learn Option fields and default values. 4 min
  6. 6 Summary - Serde Combine serde_json and derive to build a config reader. 5 min
19
Project: Blog APIProject
5 lessons · 30 min
  1. 1 Model skeleton Set up the model by adding serde derive to the Post struct. 6 min
  2. 2 Reading JSON Read a list of posts with serde_json. 6 min
  3. 3 Error handling Handle API errors with anyhow. 6 min
  4. 4 Listing records Produce a post list with an iterator. 6 min
  5. 5 CLI Build list and get subcommands with clap. 6 min
20
Intermediate finalFinal
4 lessons · 28 min
  1. 1 Generic stack Build a Vec-backed generic Stack<T> data structure. 7 min
  2. 2 Shapes with traits Write a Shape trait and types that compute area. 7 min
  3. 3 Iterator adapter Write your own type that implements Iterator. 7 min
  4. 4 JSON config reader Build a CLI that reads a config file with serde. 7 min

Master async/await, tokio, concurrency, channels, unsafe, FFI, macros, trait objects, GATs and const generics.

1
async/await
6 lessons · 25 min
  1. 1 async fn Define async functions with async fn. 4 min
  2. 2 await Wait for a future with .await. 4 min
  3. 3 Future trait Learn the Future trait's poll mechanism. 4 min
  4. 4 async block Create an anonymous future with an async {} block. 4 min
  5. 5 Pin Learn Pin<T> and why self-referential data needs it. 4 min
  6. 6 Summary - async/await Combine async fn, await and block to await two tasks in sequence. 5 min
2
Tokio
6 lessons · 25 min
  1. 1 Tokio runtime Start a runtime with #[tokio::main]. 4 min
  2. 2 spawn Spawn async tasks with tokio::spawn. 4 min
  3. 3 tokio::sync Learn async synchronization primitives from tokio::sync. 4 min
  4. 4 tokio::fs Do async file I/O with tokio::fs. 4 min
  5. 5 select! Wait on multiple futures at once with tokio::select!. 4 min
  6. 6 Summary - Tokio Race two async tasks by combining spawn and select!. 5 min
3
Concurrency
6 lessons · 25 min
  1. 1 thread::spawn Spawn OS threads with std::thread::spawn. 4 min
  2. 2 Mutex<T> Do mutual exclusion with Mutex<T>. 4 min
  3. 3 RwLock<T> Use a many-reader single-writer lock with RwLock<T>. 4 min
  4. 4 Arc<T> Share data across threads with Arc<T>. 4 min
  5. 5 Send and Sync Learn the Send and Sync marker traits and why they matter. 4 min
  6. 6 Summary - Concurrency Combine thread, Arc and Mutex to build a parallel counter. 5 min
4
Channels
6 lessons · 25 min
  1. 1 mpsc channel Create a channel with std::sync::mpsc. 4 min
  2. 2 send and recv Send and receive messages with send and recv. 4 min
  3. 3 Multiple producers Build a multi-producer channel with tx.clone(). 4 min
  4. 4 try_recv Read without blocking using try_recv. 4 min
  5. 5 tokio::sync::mpsc Learn async channels and how they differ from sync mpsc. 4 min
  6. 6 Summary - Channels Combine mpsc and thread to build a threaded work queue. 5 min
5
Project: Chat serverProject
5 lessons · 30 min
  1. 1 TCP listener Accept clients in a loop with TcpListener. 6 min
  2. 2 Client thread Spawn and manage a thread per client. 6 min
  3. 3 Channel messaging Collect and dispatch messages with mpsc. 6 min
  4. 4 Broadcast Write to all clients through a Vec<TcpStream>. 6 min
  5. 5 Arc<Mutex> state Manage shared state with Arc<Mutex<>>. 6 min
6
Unsafe Rust
6 lessons · 25 min
  1. 1 unsafe block Learn what the unsafe block allows. 4 min
  2. 2 Raw pointers Use *const T and *mut T raw pointers. 4 min
  3. 3 unsafe fn Define and call unsafe fn. 4 min
  4. 4 static mut Manage global variables with static mut. 4 min
  5. 5 FFI call Call foreign functions with extern "C". 4 min
  6. 6 Summary - Unsafe Rust Combine unsafe and raw pointers to build split_in_two. 5 min
7
FFI
6 lessons · 25 min
  1. 1 extern block Declare C functions with extern "C". 4 min
  2. 2 #[repr(C)] Define C-compatible structs with #[repr(C)]. 4 min
  3. 3 CString and CStr Convert C strings with CString and CStr. 4 min
  4. 4 Callback Pass callbacks from C into Rust. 4 min
  5. 5 Drop and cleanup Learn memory cleanup and the Drop trait in FFI. 4 min
  6. 6 Summary - FFI Combine extern, repr(C) and CString to wrap a C call sending a string. 5 min
8
Declarative macros
6 lessons · 25 min
  1. 1 macro_rules! Define macros with macro_rules!. 4 min
  2. 2 Repetitions Learn repetition patterns with $(...),*. 4 min
  3. 3 Types Write macros with type parameters like $ty:ty. 4 min
  4. 4 Macro hygiene Learn macro hygiene. 4 min
  5. 5 Inspecting println! Inspect the internals of the println! macro. 4 min
  6. 6 Summary - Declarative macros Combine macro_rules! and repetitions to build a vec_of! macro. 5 min
9
Procedural macros
6 lessons · 25 min
  1. 1 proc_macro crate Get to know the proc_macro crate and its core API. 4 min
  2. 2 derive macro Write a derive macro with #[proc_macro_derive]. 4 min
  3. 3 attribute macro Write an attribute macro with #[proc_macro_attribute]. 4 min
  4. 4 syn and quote Generate code with the syn and quote crates. 4 min
  5. 5 TokenStream Produce streaming code with TokenStream. 4 min
  6. 6 Summary - Procedural macros Combine derive, syn and quote to write a HelloMacro derive. 5 min
10
Trait objects
6 lessons · 25 min
  1. 1 dyn Trait Do dynamic dispatch with dyn Trait. 4 min
  2. 2 Box<dyn Trait> Own a trait object with Box<dyn Trait>. 4 min
  3. 3 Static vs dynamic dispatch Learn the difference and cost of static vs dynamic dispatch. 4 min
  4. 4 Object safety Learn the object safety rules. 4 min
  5. 5 &dyn Trait Do reference-based dispatch with &dyn Trait. 4 min
  6. 6 Summary - Trait objects Combine Box<dyn Trait> and the vtable to build a list of shapes. 5 min
11
Advanced traits
6 lessons · 25 min
  1. 1 Associated type Define an associated type in a trait. 4 min
  2. 2 Associated constant Define an associated constant. 4 min
  3. 3 GAT Learn Generic Associated Types (GATs). 4 min
  4. 4 Supertrait Constrain a trait with another trait using a supertrait. 4 min
  5. 5 Newtype pattern Resolve trait conflicts with the newtype pattern. 4 min
  6. 6 Summary - Advanced traits Combine associated types and supertraits to write a Graph trait. 5 min
12
Const generics
6 lessons · 25 min
  1. 1 [T; N] Learn generic types with const parameters. 4 min
  2. 2 const fn Write compile-time functions with const fn. 4 min
  3. 3 Const trait bound Use trait bounds with const generics. 4 min
  4. 4 Min_const_generics Learn the limits and valid uses of min_const_generics. 4 min
  5. 5 Array and slice Do array operations with const generics. 4 min
  6. 6 Summary - Const generics Combine const fn and [T; N] to build a generic dot product. 5 min
13
Advanced patterns
6 lessons · 25 min
  1. 1 Struct patterns Destructure struct fields with patterns. 4 min
  2. 2 Destructuring Learn tuple and struct destructuring. 4 min
  3. 3 @ binding Bind a value range with the @ operator. 4 min
  4. 4 Guard Add a condition to a pattern with if guard. 4 min
  5. 5 Binding modes Learn binding modes with ref and ref mut. 4 min
  6. 6 Summary - Advanced patterns Combine struct, @ and guard to build a color classifier. 5 min
14
Advanced finalFinal
4 lessons · 28 min
  1. 1 Async web server Build a mini server that handles clients in parallel with tokio. 7 min
  2. 2 ThreadPool Build your own ThreadPool with Mutex and mpsc. 7 min
  3. 3 derive macro Write and test a custom derive macro. 7 min
  4. 4 FFI wrapper Write a safe wrapper around a C library. 7 min

Reach Rust mastery with compiler internals, memory layout, zero-cost abstraction, SIMD, inline assembly, no_std, embedded and build tools.

1
Compiler internals
6 lessons · 25 min
  1. 1 HIR Learn what High-level IR (HIR) is and what it does. 4 min
  2. 2 MIR Learn Mid-level IR (MIR) and its role in borrow checking. 4 min
  3. 3 LLVM IR Learn the LLVM backend and code generation pipeline. 4 min
  4. 4 Borrow checker Learn how the borrow checker runs on MIR. 4 min
  5. 5 Type inference Learn the Hindley-Milner style type inference algorithm. 4 min
  6. 6 Summary - Compiler internals Combine HIR, MIR and LLVM IR to draw a compilation pipeline. 5 min
2
Memory layout
6 lessons · 25 min
  1. 1 Struct layout Learn how struct fields are laid out in memory. 4 min
  2. 2 #[repr(C)] and #[repr(Rust)] Learn the difference between #[repr(C)] and #[repr(Rust)]. 4 min
  3. 3 Alignment and padding Learn alignment and padding. 4 min
  4. 4 ZST Learn zero-sized types (ZSTs) and their advantages. 4 min
  5. 5 Niche optimization Shrink enum size with niche optimization. 4 min
  6. 6 Summary - Memory layout Combine repr, alignment and ZST to write a memory analysis. 5 min
3
Zero-cost abstraction
6 lessons · 25 min
  1. 1 Cost of abstraction Learn how to measure the cost of abstraction. 4 min
  2. 2 Monomorphization Learn the cost of generics through monomorphization. 4 min
  3. 3 Iterator fusion Optimize with iterator fusion. 4 min
  4. 4 #[inline] Learn the #[inline] attribute and its effects. 4 min
  5. 5 Bounds check Learn bounds checks and how to avoid them. 4 min
  6. 6 Summary - Zero-cost abstraction Combine monomorphization, fusion and inline to write a performance comparison. 5 min
4
SIMD
6 lessons · 25 min
  1. 1 std::simd Get started with packed operations via std::simd. 4 min
  2. 2 Simd<T, N> Use the Simd<T, N> vector type. 4 min
  3. 3 Mask Do conditional packed operations with Mask. 4 min
  4. 4 Horizontal ops Use horizontal operations like horizontal_reduce. 4 min
  5. 5 Auto-vectorization Learn compiler auto-vectorization. 4 min
  6. 6 Summary - SIMD Combine Simd<T, N> and Mask to build a vector sum. 5 min
5
Inline assembly
6 lessons · 25 min
  1. 1 asm! macro Write assembly with core::arch::asm!. 4 min
  2. 2 Operands Use in, out and inout operands. 4 min
  3. 3 Registers Specify explicit registers. 4 min
  4. 4 Options Use the pure, nomem and nostack options. 4 min
  5. 5 CPUID Invoke special instructions like CPUID. 4 min
  6. 6 Summary - Inline assembly Combine asm!, in/out and options to read time with rdtsc. 5 min
6
no_std and embedded
6 lessons · 25 min
  1. 1 no_std Learn the no-stdlib environment with #![no_std]. 4 min
  2. 2 alloc crate Use the heap with the alloc crate. 4 min
  3. 3 Embedded Program microcontrollers with embedded-hal. 4 min
  4. 4 WebAssembly Produce WebAssembly with the wasm32 target. 4 min
  5. 5 Panic handler Handle panics with #[panic_handler]. 4 min
  6. 6 Summary - no_std and embedded Combine no_std, alloc and panic_handler to write an embedded skeleton. 5 min
7
Build tools
6 lessons · 25 min
  1. 1 build.rs Run pre-build code with build.rs. 4 min
  2. 2 Cross compilation Cross-compile with the cross tool. 4 min
  3. 3 Linker Learn linker selection and LTO settings. 4 min
  4. 4 Profiling Profile with perf and flamegraph. 4 min
  5. 5 Unsafe guidelines Learn unsafe Rust writing guidelines and a checklist. 4 min
  6. 6 Summary - Build tools Combine build.rs, LTO and flamegraph to write a build report. 5 min
8
Expert finalFinal
4 lessons · 28 min
  1. 1 Allocator Write your own allocator with unsafe. 7 min
  2. 2 SIMD matrix Do parallel matrix multiplication with SIMD. 7 min
  3. 3 no_std runtime Write a minimal runtime for no_std. 7 min
  4. 4 Profiled optimization Improve performance with flamegraph. 7 min

Lessons are free, an account keeps your progress

You do not have to sign up. If you do, you continue where you left off and never lose your work.

  • Progress saved on every device
  • Earn XP and badges
  • Keep your daily streak
  • Get a certificate when you finish
create a free account

Frequently asked questions

Are the Rust lessons free?

Yes. All 357 lessons of the Rust course are free and you can start without an account.

Do I need any prior knowledge?

No. The beginner level starts from zero; a browser is all you need. If you already know the basics, start at a higher level.

How long does the course take?

Lessons take 2–8 minutes. The whole course is about 27 hours; with 15–20 minutes a day you can finish in a few months.

Do I get a certificate?

Yes. When you complete the course with a free account, a verifiable certificate is issued in your name.

Will I lose my progress without an account?

Without an account your progress is kept only in your current browser. When you create a free account it is moved to your account.

Next step Go

Build efficient microservices with Go's clean syntax and powerful concurrency model. Goroutine, channel, interface and the standard library.