I am trying to understand why the following code compiles with no errors:
fn consume(w: &mut Vec<i32>) {
drop(w); // dropping w
}
fn main() {
let mut v = vec![10,11];
consume(&mut v);
v.push(12); // still using v after drop?
}
In my understanding, since we are dropping the mutable reference to v, v points to a freed memory location after the call to consume(). Can someone explain to me why this code compiles fine, and the compiler does not complain about a dangling pointer?