Medium
Pushing to a Vec while iterating over it
What happens when this program is compiled?
main.rs
fn main() {
let mut v = vec![1, 2, 3];
for x in &v {
v.push(*x);
}
println!("{:?}", v);
}10 of 53 in Rust
What happens when this program is compiled?
fn main() {
let mut v = vec![1, 2, 3];
for x in &v {
v.push(*x);
}
println!("{:?}", v);
}