Practice
Learn
← Quit
0 / 0 correct
Rust
Hard
1 of 10
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
x must be mutable
C
push needs i64
D
v is borrowed immutably by the loop iterator while push needs a mutable borrow