You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This simple code compiles on current master (0d3bd77) :
fn main() {
let mut vector = vec!(1u, 2u);
for &x in vector.iter() {
let cap = vector.capacity();
println!("Capacity was: {}", cap);
vector.grow(cap, &0u); // be sure to cause reallocation
*vector.get_mut(1u) = 5u;
println!("Value: {}", x);
}
}
and outputs:
Capacity was: 4
Value: 1
Capacity was: 8
Value: 2
while on 0.11 the borrow checker would complain that vector is already immutably borrowed by vector.iter().
It allows me to write 5u in vector[1] and then read it as 2u, because reallocation of the vector caused the iterator's slice to refer to freed memory.