I'm looking at some code that looks like this:
for mut i in 2..points.len() {
// Do something
if some_condition {
i += 1;
}
}
It compiles and runs fine (it seems). My first intuition was that it would be better as a while loop.
Then I started wondering, is this something that's legal to do in Rust in general?
What happens if you happen to increment i beyond the range? I'm guessing trouble obviously...
I'd like to know if there are any kind of issues modifying the index while going through the range with it. I'm assuming that the i stays in range, but I would be interested to know what happens when it goes beyond the range too.