I'm currently working my way through the rustlings course and got confused when this exercise regarding move-semantics came up. Here is the gist of it:
fn main(){
let vec0 = Vec::new();
let mut vec1 = fill_vec(vec0);
//stuff happens
}
fn fill_vec(vec: Vec<i32>) -> Vec<i32> {
let mut vec = vec;
//do stuff
vec
}
From what I can tell, the immutable vec0 is being moved to fill_vec as parameter vec, which is then being mutably shadowed by let mut vec = vec;. Since Vectors are references to heap-storage, does this imply that a clone() takes place due to the shadowing, or is the same pointer reused and just made mutable? Why would shadowing be used in this case at all?