Skip to main content

Ownership without the fear

Ownership is the one idea that makes the rest of Rust make sense: every value has exactly one owner, and when the owner goes out of scope the memory is freed. No garbage collector, no pauses.

You will deliberately trigger the classic `E0382` error here. Breaking it yourself is the fastest way to stop being surprised by it later.

Step 1 of 3

Break it on purpose

Create a `String`, assign it to a second variable, then try to print the first one. Expect the build to fail.

Assigning a heap value moves ownership. The original binding is no longer usable, and Rust tells you at compile time instead of crashing later.

Checkpoints

  • A `String` is created and moved to another binding — not yet passed
  • The compiler reports a borrow-of-moved-value error (E0382) — not yet passed