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
push needs i64
B
for loops consume the vector
C
v is borrowed immutably by the loop iterator while push needs a mutable borrow
D
x must be mutable