Learning path

Ownership and borrowing

Moves, references, slices, lifetimes and smart pointers: the ideas that keep Rust memory-safe without a garbage collector.

5 lessons · 7 challenges

  1. Lesson 1 challenge Ownership and Moves Learn the rule behind Rust's memory safety: every value has one owner.
  2. Lesson 2 challenges References and Borrowing Let a function use a value without taking ownership of it.
  3. Lesson 2 challenges Slices Borrow part of a string or array without copying it.
  4. Lesson 1 challenge Lifetimes Tell the compiler how long references stay valid with lifetime annotations.
  5. Lesson 1 challenge Smart Pointers: Box and Rc Put data on the heap with Box and share ownership with Rc.