I am currently porting some c++ code to Rust. That code used ancient C for loops as expected. If I simplify that for-loop, it boils down to this:
for(int cur = 0; cur < 11; ++cur){
std::cout << cur << std::endl;
if(cur == 4) {
// Change the index
cur = 8;
}
}
To say exactly, that code needs to change cur
while iteration. That example code outputs:
0
1
2
3
4
9
10
I am a novice in Rust so I coded it as:
for mut cur in 0..11 {
println!("{:?}", cur);
if cur == 4 {
cur = 8;
}
}
and it doesn't work:
0
1
2
3
4
5
6
7
8
9
10
Sorry for asking this dumb question. Any kind of help or tip will be well appreciated!
Thanks!