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