#Reborrowing question
5 messages · Page 1 of 1 (latest)
Nothing, it still exists
I believe its because you never assign *v to a variable. The first argument to Vec::push is a temporary variable so it doesnt need to move out of the *v
Oh no. That's wrong. I have no idea then. It does seem weird
Note that this does compile:
fn main(){
let mut v = vec![1];
foo(&mut v);
}
fn foo(v: &mut Vec<i32>) {
let reborrow = &mut *v;
Vec::push(reborrow, 0);
Vec::push(v, 0);
}
But this doesnt compile
fn main(){
let mut v = vec![1];
foo(&mut v);
}
fn foo(v: &mut Vec<i32>) {
let reborrow = &mut *v;
Vec::push(reborrow, 0);
Vec::push(v, 0);
Vec::push(reborrow, 0);
}