We can't find the internet
Attempting to reconnect
Something went wrong!
Attempting to reconnect
Ownership I: Moves, Copy, Clone, Drop
RustFollow 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.
Your learning sequence
- 1 Not solved yet. The three rules of ownership Practice · Easy
- 2 Not solved yet. Stack, heap, and what a variable actually holds Practice · Easy
- 3 Not solved yet. Move semantics: the relay Practice · Easy
- 4 Not solved yet. Reading E0382 line by line Practice · Easy
- 5 Not solved yet. Copy values: translate points and find their centroid Practice · Easy
- 6 Not solved yet. Move values through a pipeline without cloning Practice · Easy
- 7 Copy and Drop are mutually exclusive Read
- 8 Not solved yet. Ownership through function calls Practice · Easy
- 9 Not solved yet. Giving ownership back Practice · Medium
- 10 Not solved yet. Partial moves: taking one field and leaving the rest Practice · Medium
- 11 Not solved yet. Take a payload while keeping its destructor valid Practice · Hard
- 12 Not solved yet. Schedule destruction with a by-value helper Practice · Easy
- 13 Not solved yet. Observe scope cleanup and control vector drop order Practice · Medium
- 14 Not solved yet. Moving out of &mut: take, replace, swap Practice · Medium
- 15 Not solved yet. Conditional moves and drop flags Practice · Hard
- 16 Not solved yet. Ownership inside loops Practice · Medium
- 17 Not solved yet. Shadowing is not moving Practice · Easy
- 18 Not solved yet. Method receivers and the consuming builder Practice · Medium
- 19 Not solved yet. Observe when destructors are skipped Practice · Hard
- 20 Choose between cloning, moving and borrowing Read
Check yourself
3 questions · not saved while you're signed outUse these questions to check your understanding and compare explanations. Your score does not affect track completion.
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}");
}