Ownership: who owns this value?
Most languages solve memory with a garbage collector that pauses your program to clean up. Rust solves it at compile time instead: every value has exactly one owner, and when that owner goes out of scope the value is freed. No collector, no pauses, no leaks.
The consequence people trip over is the *move*. Assigning a `String` to another variable does not copy it — it transfers ownership. The original variable is now empty as far as the compiler is concerned, and using it is a compile error rather than a crash at 3am.
Small values like integers implement `Copy`, so they are duplicated instead of moved. That is why the counter below still works after being handed to another variable.
The error everyone hits first
fn main() {
let original = String::from("hello");
let moved = original;
println!("{original}"); // original no longer owns anything
}error[E0382]: borrow of moved value: `original`
Either use `moved` from now on, or call `original.clone()` when you genuinely need two independent copies. Cloning is explicit in Rust so the cost is always visible in the source.
Run it and change it
The editor below is live: edit anything and the real compiler output updates by itself.