Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardRustDrop plus move interactionSingle-choice MCQ

Why does Rust forbid moving a field out of a value whose type implements `Drop`, as in the snippet below?

struct Wrapper { inner: String } impl Drop for Wrapper { fn drop(&mut self) { /* ... */ } } fn take(w: Wrapper) -> String { w.inner // error[E0509]: cannot move out of type which implements Drop }