---
title: "Learn Rust"
slug: "learn-rust"
description: "Write, read and test small Rust programs: ownership, borrowing, enums, Result and ?, traits, lifetimes, iterators and a tested command-line tool."
published: "2026-12-03"
updated: "2026-12-03"
canonical: "https://aifree.dev/courses/learn-rust"
---

# Learn Rust

Write, read and test small Rust programs: ownership, borrowing, enums, Result and ?, traits, lifetimes, iterators and a tested command-line tool.

Rust · Beginner · 113 min

## 1. First steps

- [Install Rust and run your first program](https://aifree.dev/courses/learn-rust/hello-cargo.md) (8 min): Install Rust with rustup, create a project with cargo new and run it with cargo run. See what fn main and println! do and how run, build and check differ.
- [Variables, mut and shadowing in Rust](https://aifree.dev/courses/learn-rust/variables-and-mutability.md) (10 min): Learn why let variables are immutable, add mut to change one, use const and see how shadowing differs from mut. Fix the error for assigning twice.

## 2. Ownership and types

- [Ownership and moves in Rust](https://aifree.dev/courses/learn-rust/ownership-and-moves.md) (10 min): Learn the three ownership rules, how a String moves when you assign it or pass it to a function, and when to clone. Fix a use of a moved value.
- [Borrowing and references in Rust](https://aifree.dev/courses/learn-rust/borrowing-and-references.md) (10 min): Use & to borrow a value and &mut to change it without moving it. Learn the rule of one mutable or many shared references, and fix two overlapping borrows.
- [Structs, enums and match in Rust](https://aifree.dev/courses/learn-rust/structs-enums-and-match.md) (12 min): Define structs with methods in an impl block, enums that carry data, and use match and if let to handle every case, including Option. Fix a missing arm.

## 3. Errors and traits

- [Option, Result and the ? operator in Rust](https://aifree.dev/courses/learn-rust/option-result-and-question-mark.md) (12 min): Handle a missing value with Option and a failing call with Result, and pass errors up with the ? operator. Fix ? used in a main that returns nothing.
- [Traits in Rust: shared behaviour](https://aifree.dev/courses/learn-rust/traits.md) (12 min): Share behaviour between types with traits: default methods, trait bounds, derive, Display and Box<dyn Trait>. Fix a type that is missing its impl.

## 4. Lifetimes, iterators and projects

- [Lifetimes in Rust: how long a reference lives](https://aifree.dev/courses/learn-rust/lifetimes.md) (12 min): See how lifetimes tell the compiler how long a reference is valid: longest, structs that hold a reference and elision. Fix a missing lifetime specifier.
- [Iterators and closures in Rust](https://aifree.dev/courses/learn-rust/iterators-and-closures.md) (12 min): Write closures that capture variables and chain iterator adapters such as map and filter. See why iterators are lazy and fix a use after into_iter.
- [Crates, modules and cargo test](https://aifree.dev/courses/learn-rust/crates-modules-and-tests.md) (15 min): Split code into modules, make items pub, write unit tests and run cargo test. Fix a private function, then build a small tested command-line tool.

## Free AI coding tools to practise with

1. [AgentRouter Free Credits](https://aifree.dev/offer/agentrouter-free-credits.md) : Free AI coding credits: $25 per daily check-in and $50 per invite. No card. Verified 2026-11-28. Claim: https://agentrouter.org/register?aff=N5wg
2. [Cursor Free Plan](https://aifree.dev/offer/cursor-hobby-plan.md) : Cursor Agent with limited agent and chat requests, $0/month. No card. Verified 2026-11-29. Claim: https://cursor.com/pricing?ref=aifree.dev
3. [Cline Free Models](https://aifree.dev/offer/cline-free-models.md) : Try select models free in Cline via rotating promotions with a usage quota. No card. Verified 2026-11-06. Claim: https://cline.bot?ref=aifree.dev

[All offers](https://aifree.dev/free-ai-coding-tools.md)
