Rust Tutorial
Master Rust from scratch with our comprehensive, interactive curriculum — 50 lessons from Beginner to Advanced.
Learn Rust from scratch — ownership, borrowing, structs, enums, traits, generics, lifetimes, iterators and concurrency — free interactive lessons.
Part of the free Rust course at LearnCodingFast — hands-on lessons with examples you run in your browser, plus practice exercises and a quick quiz.
Start with Lesson 1 and build real skills step by step — at your own pace.
Lessons in this course
- Introduction to Rust — Install Rust, run your first program with Cargo, and see why Rust exists
- Variables & Mutability — Understand immutable-by-default variables, mut, constants, and shadowing
- Data Types — Integers, floats, booleans, chars, tuples, and arrays in a statically typed language
- Functions — Define functions, pass parameters, and return values with expressions
- Control Flow — Branch with if/else and loop with loop, while, and for
- Ownership — Rust's signature feature — how memory is managed without a garbage collector
- References & Borrowing — Borrow values with & and &mut without giving up ownership
- Slices — Reference contiguous sections of collections without copying them
- Structs — Group related data together and attach behaviour with methods
- Enums & Pattern Matching — Model values that can be one of several variants and match on them
- Option & Result — Handle absence and failure safely without null or exceptions
- Vectors — Store growable lists of values with Vec<T>
- Strings — Work with String and &str, and understand UTF-8 text in Rust
- HashMaps — Map keys to values for fast lookups with HashMap<K, V>
- Error Handling (the ? operator) — Propagate recoverable errors cleanly with Result and the ? operator
- Modules & Crates — Organise code with modules, paths, and external crates from crates.io
- Generics — Write code that works over many types without duplication
- Traits — Define shared behaviour and program to interfaces with trait bounds
- Lifetimes — Tell the compiler how long references are valid to prevent dangling pointers
- Closures — Anonymous functions that capture their environment — Fn, FnMut, FnOnce
- Iterators — Process sequences lazily with map, filter, collect, and the Iterator trait
- Smart Pointers (Box, Rc, RefCell) — Heap allocation, shared ownership, and interior mutability
- Concurrency & Threads — Spawn threads and pass messages safely with Rust's fearless concurrency
- Cargo, Crates & the Module Workflow — cargo new/build/run/test, Cargo.toml, and organising code into modules
- Operators & Expressions — Arithmetic, overflow handling, comparison, and everything-is-an-expression
- Tuples & Arrays — Fixed-size groupings — destructuring tuples and indexing arrays safely
- String Formatting (format!, println!) — {} vs {:?}, width/precision/alignment, and named & inline args
- Pattern Matching (match, if let, while let) — Exhaustive match, ranges, guards, bindings, and let-else
- Type Conversions (From, Into, as, TryFrom) — Cast with as, convert with From/Into, and fallibly with TryFrom
- Constants & Statics — const vs static, const fn, and compile-time evaluation
- Comparison & Ordering (PartialEq, Ord) — Derive equality and ordering, sort with keys, and why floats are PartialOrd
- Checkpoint: Rust Basics — Combine parsing, sorting and formatting in a build — then a quiz
- Trait Objects & dyn — Dynamic dispatch with dyn Trait and Box<dyn Trait> vs generics
- Associated Types & Trait Bounds — type Item in traits, implementing Iterator, and where clauses
- Derive Macros (#[derive]) — What Debug, Clone, Copy, PartialEq, Hash and Default generate for you
- Operator Overloading (std::ops) — Implement Add, Mul and Index for your own types
- The Default & Clone Traits — Default::default(), struct update syntax, and Clone vs Copy
- Testing (#[test], cargo test) — Write unit tests with assert_eq!, #[should_panic], and cfg(test)
- File I/O (std::fs) — Read and write files with fs, BufReader, and the ? operator
- Command-Line Args (std::env) — Read args and environment variables to build CLI programs
- Checkpoint: Traits & Generics — Build a shapes program with traits and trait objects — then a quiz
- More Collections: VecDeque, BTreeMap & BinaryHeap — Pick the right collection — deques, sorted maps, heaps, and sets
- Declarative Macros (macro_rules!) — Write your own macros with matchers, repetition, and hygiene
- The Drop Trait & RAII — Run cleanup automatically at scope end — Rust's no-GC resource model
- The Newtype Pattern & Type Aliases — Add type safety with wrapper structs and the orphan-rule workaround
- Cow: Clone-on-Write — Avoid allocations by borrowing until you actually need to own
- Error Handling with Box<dyn Error> — Mix error types with ? and a boxed trait object, including in main()
- unsafe Rust — Raw pointers and the five unsafe superpowers — used soundly
- Checkpoint: Systems Rust — Combine a newtype, a macro and Box<dyn Error> in a build — then a quiz
- Capstone: A CLI Tool — Bring it all together by building a real command-line application
- Async Rust with Tokio — async/await, futures, the Tokio runtime, spawning tasks, and channels
- Web Framework with Axum — Build an HTTP server with Axum — routers, handlers, extractors, and state
- Database Access with sqlx — Compile-time-checked SQL, connection pools, FromRow mapping, and transactions
- FFI & C Interop — Call C from Rust and Rust from C with extern, repr(C), and the FFI types
- Serialization with Serde — Derive Serialize/Deserialize and work with JSON and other formats
- Error Handling with thiserror & anyhow — Ergonomic library and application errors beyond Box<dyn Error>
- Send, Sync & Shared-State Concurrency — The thread-safety marker traits and Arc<Mutex<T>> shared state
- Procedural & Derive Macros — Write your own derive, attribute and function-like macros with syn and quote
- Benchmarking with Criterion — Statistical benchmarks with cargo bench, black_box and HTML reports
- Cargo Workspaces & Publishing — Multi-crate workspaces and publishing to crates.io with cargo publish