1. Ownership Rules and Memory
Rust's ownership system rests on three simple rules that govern every value in the language: every value has exactly one owner, there can only be a single owner at any given moment...
Read full chapter →The essential Rust Ownership And Borrowing Explained cheat sheet: 8 concise chapters you can read in minutes, distilled from the full deck. When you're ready, drill the flashcards or test yourself under exam conditions.
Rust's ownership system rests on three simple rules that govern every value in the language: every value has exactly one owner, there can only be a single owner at any given moment...
Read full chapter →When you assign a value to another variable or pass it to a function, Rust moves the value rather than copying it by default. After a move, the source binding is invalidated, and a...
Read full chapter →Borrowing is the act of letting another piece of code access your value without taking ownership, by handing out a reference. A shared reference &T permits read-only access, wh...
Read full chapter →Lifetime annotations are the mechanism by which the borrow checker understands how multiple references relate in time. Written as generic parameters like 'a, they appear in functio...
Read full chapter →A slice is a reference to a contiguous sequence of elements, written &[T] for a shared slice or &mut [T] for a mutable slice. Slices always borrow data and consist of a poi...
Read full chapter →Interior mutability is a family of patterns that allows mutation through a shared reference, with the borrowing rules enforced at runtime rather than at compile time. This is neede...
Read full chapter →When multiple parts of a program legitimately need to own the same data, Rust offers reference-counted smart pointers. Rc<T> is the single-threaded choice: cloning an Rc<T...
Read full chapter →Pattern matching interacts with ownership in subtle but useful ways. By default, destructuring a struct or tuple in a let or match moves the fields out — prefix a binding with ref...
Read full chapter →Done reading?
Test yourself with the Rust Ownership And Borrowing Explained practice exam — timed questions, instant score, full review of wrong answers. Free.
🎯 Take the Practice Exam →