Practice
Learn
← Quit
0 / 0 correct
Rust
Hard
1 of 20
Why does this fail to compile?
let mut v = vec![1, 2, 3]; for x in &v { if *x == 2 { v.push(5); } }
A
v is borrowed immutably by the loop iterator while push needs a mutable borrow
B
push needs i64
C
for loops consume the vector
D
x must be mutable