Skip to content
← All Rust tracks

Ownership I: Moves, Copy, Clone, Drop

Rust

Follow values as they move, copy, clone and drop. Use compiler errors and destruction logs to understand who owns each value.

This track uses Rust. You can make it your practice mode to browse related content across the site.

18 exercises

2 articles

Explore freely. Sign in to keep your progress.

Your learning sequence

  1. 1 Not solved yet. The three rules of ownership Practice · Easy
  2. 2 Not solved yet. Stack, heap, and what a variable actually holds Practice · Easy
  3. 3 Not solved yet. Move semantics: the relay Practice · Easy
  4. 4 Not solved yet. Reading E0382 line by line Practice · Easy
  5. 5 Not solved yet. Copy values: translate points and find their centroid Practice · Easy
  6. 6 Not solved yet. Move values through a pipeline without cloning Practice · Easy
  7. 7 Copy and Drop are mutually exclusive Read
  8. 8 Not solved yet. Ownership through function calls Practice · Easy
  9. 9 Not solved yet. Giving ownership back Practice · Medium
  10. 10 Not solved yet. Partial moves: taking one field and leaving the rest Practice · Medium
  11. 11 Not solved yet. Take a payload while keeping its destructor valid Practice · Hard
  12. 12 Not solved yet. Schedule destruction with a by-value helper Practice · Easy
  13. 13 Not solved yet. Observe scope cleanup and control vector drop order Practice · Medium
  14. 14 Not solved yet. Moving out of &mut: take, replace, swap Practice · Medium
  15. 15 Not solved yet. Conditional moves and drop flags Practice · Hard
  16. 16 Not solved yet. Ownership inside loops Practice · Medium
  17. 17 Not solved yet. Shadowing is not moving Practice · Easy
  18. 18 Not solved yet. Method receivers and the consuming builder Practice · Medium
  19. 19 Not solved yet. Observe when destructors are skipped Practice · Hard
  20. 20 Choose between cloning, moving and borrowing Read

Check yourself

3 questions · not saved while you're signed out

Use these questions to check your understanding and compare explanations. Your score does not affect track completion.

0 / 3 correct

After a + &b, which of a, b and c can still be used to read a string?

Choose one answer to reveal the explanations. Answers are kept only while this page is open.

fn main() {
    let a = String::from("foo");
    let b = String::from("bar");
    let c = a + &b;
    println!("{c} {b}");
}
Question 1 of 3