btw, I'm not aware what bug you are talking about.
whether nor not the container would pre-allocate should be a performance optimization, it should not change the correctness of user code. so I don't know what's your concerns are.
as for reusing exisitng allocation, yes, Vec does have special treatment to reuse exisiting storage special cases, notably, code like this will do the transformation in-place, no allocation/deallocaton/reallocation would occur:
let mut xs: Vec<i32> = vec![1, 2, 3];
xs = xs.into_iter().map(|x| x+1).collect(); //<-- no reallocation happens here
but an existing Vec reusing its allocation and a new Vec reserving storage (pre-allocating) are different problems. in your example, there are no reusing because the old my_vector stil exists. maybe you meant to use my_vec.into_iter() (as opposed to my_vec.iter())?
maybe related previouis discussions: