Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardRustdrop order and drop glueSingle-choice MCQ

In what order are the destructors run for this program, given how a temporary created in the scrutinee of a `match` is scoped relative to a value bound inside the matched arm?

struct G(&'static str); impl Drop for G { fn drop(&mut self) { println!("drop {}", self.0); } } impl G { fn tag(&self) -> i32 { 0 } } fn main() { match G("scrut").tag() { _ => { let _inner = G("inner"); println!("arm"); } } println!("after"); }