|
|
|
|
|
by apendleton
1302 days ago
|
|
In Rust at least, once you instantiate the iterator, the array it's iterating over can't be mutated until the iterator is dropped, and that can be statically guaranteed at compile time. So you don't need to bounds-check at every access; you can decide at the outset how many iterations there are going to be, and doing that number of iterations will be known not to walk past the end. |
|
That said, this is unavoidable in C/C++ too.