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

Given `D` implements `Drop`, why does `let d = *b;` (moving out of a `Box<D>`) compile, while moving a field out of a struct that implements `Drop` is rejected with E0509?

struct D(i32); impl Drop for D { fn drop(&mut self) { println!("drop {}", self.0); } } fn main() { let b = Box::new(D(7)); let d = *b; // compiles println!("{}", d.0); }