Curriculum Ownership & borrowing
module 2 of 7
Ownership & borrowing
Rust's core alien model. Moves, copies, references, mutable borrows, slices, String vs &str, and enough lifetime intuition to make the borrow checker feel like a set of rules rather than a personality.
Themes
2.1
Moves and Copy
TypeScript variables point at values managed by a garbage collector;
Rust bindings own values unless the type is Copy. This theme makes
moves concrete before references appear. P…
2.2
Shared borrowing
Borrowing is how Rust lets code inspect data without taking it. &T
references are shared, read-only views whose owner remains somewhere
else. Planned exercises: 1. choose `&Strin…
The borrow checker's headline rule is simple but unfamiliar: many
shared borrows or one mutable borrow, never both at the same time.
This theme teaches &mut T, reborrowing, and s…
Rust has owned strings (String) and borrowed string slices (&str).
The same borrowed-view idea applies to slices like &[T]. This theme
teaches the signature reflex: accept `&…
Lifetimes are not a separate runtime feature; they describe how long references are valid. This theme avoids advanced annotation syntax at first and focuses on why Rust rejects dan…