Tag: ownership
-
What happens when assigning to the underscore pattern?
17 This is a question from Rust quiz 28: struct Guard; impl Drop for Guard { fn drop(&mut self) { print!("1"); } } fn main() { let _guard = Guard; print!("3"); let _ = Guard; print!("2"); } Such code prints 3121, in the third line of main, assigning to _ means a immediate drop. However,…