The Complete Rust Learning Guide
Rust is a compiled systems programming language designed to help developers build fast software while preventing many common memory and concurrency mistakes.
How Rust works
Rust checks how values are owned and borrowed at compile time. These rules help determine when memory can be safely used and released, often without a garbage collector.
What you will learn
You will start with a small program, then learn ownership, borrowing, types, collections, error handling, modules, traits, and larger applications.
How to use this guide
- Start with Chapter 1 and move through the chapters in order. New ideas build on the earlier ones.
- Type each example yourself, make a small change, and predict what will happen before running it.
- When a chapter is ready, its lesson will appear at the chapter link. These pages are currently blank lesson starters.
A step-by-step learning path
- Chapters 1-7: Learn the Rust foundations. Compile a program, work with typed values, handle input and output, control flow, and functions.
- Chapters 8-12: Learn to represent and use data. Work with vectors and slices, process strings, practice borrowing, understand ownership, and define structs and enums.
- Chapters 13-18: Organize reliable programs. Learn visibility, modules and crates, the standard library, files,
Resultand other error tools, debugging, and tests. - Chapters 19-24: Build larger systems. Study algorithms, traits and generics, safe performance, Cargo workflows, and guided projects.
Rust ideas you will meet early
- Ownership: each value has a clear owner. When the owner goes away, Rust can clean up the value automatically.
- Borrowing: a reference lets code use a value without taking ownership of it. Rust checks that references are used safely.
- Result: a type used to represent either a successful value or an error. Programs decide how to handle each case.
- Cargo: Rust's standard tool for creating projects, compiling code, running tests, and managing dependencies.
Your first Rust program
Save this program as main.rs:
fn main() {
println!("Hello, world!");
}
fn starts a function definition. main is the starting function for this program. println! is a macro that prints text and a new line. With Rust installed, compile and run the standalone file:
rustc main.rs
./main
On Windows, the compiled program is named main.exe. For projects, Cargo is usually more convenient: cargo new hello creates a project and cargo run builds and runs it from that project folder.
A simple way to study
- When the compiler reports a borrowing or ownership error, use it to learn which value is being used and who owns it.
- Start with owned values and simple functions before exploring lifetimes, traits, or advanced generics.
- Use Cargo for project exercises and run
cargo testafter adding tests. - Change one thing at a time, compile again, and explain what the compiler checked.
First file: save a standalone program as main.rs and compile it with rustc main.rs, or create a Cargo project to manage a larger program.
Course chapters
Follow the 24 chapters in order, or choose a topic to revisit. Each chapter opens its own lesson page.
- What Rust is and how a program runs
- Your first program
- Values, types, and variables
- Input and output
- Expressions and operators
- Decisions and loops
- Functions and program structure
- Collections: arrays, lists, and slices
- Strings and text
- References, pointers, and memory
- Memory and resource management
- User-defined types and data modeling
- Scope, lifetime, and visibility
- Modules, imports, and declarations
- Multi-file programs, packages, and libraries
- The standard library and ecosystem
- File input and output
- Errors, debugging, and testing
- Data structures and algorithms
- Advanced language topics
- Safety, portability, and performance
- Build systems and professional workflow
- A project ladder
- Further study checklist