← All Exercises
Ownership and Move Semantics
basicrust
Background
Ownership is Rust unique feature that guarantees memory safety without garbage collection.
Problem
Show how Rust ownership prevents use-after-free through move semantics at compile time.
Input
Variables being moved and borrowed
Output
Compile-time safety guarantees
Sample tests
Sample 1
Input: let s1 = String; let s2 = s1;
Expected: s1 invalid after move
Your solution
Learning objective
Understand Rust ownership, borrowing, and lifetimes