Curriculum/ownership-rules
Ownership Rules
memory model·L0 · atom·stub
Replacesthe belief that memory management is a runtime concern.
Rust's ownership rules are three: (1) every value has exactly one owner, (2) ownership transfers on assignment or function call (move semantics), (3) values are dropped (destructor runs) when the owner goes out of scope. Stack/heap distinction is preserved; reference counting is opt-in (`Arc<T>`); garbage collection is absent. The compile-time guarantee: no use-after-free, no double-free, no data race.
Prerequisites
Bridges
- unique-ptr-cppmodel to implementationC++ `std::unique_ptr<T>` IS Rust's `Box<T>` — single owner, move-only, RAII. The difference is that C++ allows you to violate the contract (raw pointer escape) while Rust does not (no escape from the type system without `unsafe`).
- affine-types-type-theoryshared mechanismMove semantics is the affine-type-system property: a value can be used at most once. Linear types (used exactly once) are a stricter variant; affine types (Rust's actual model) allow drop. The formal foundation is from Girard's linear logic (1987) via Wadler.
This concept is a node in the curriculum DAG. The full lab — page blocks, done state, references — has not been authored yet. The relations above describe where it sits in the graph.
Author at: content/concepts/ownership-rules/card.ts