Hacker News new | ask | show | jobs
by froydnj 1542 days ago
Just because indexing is bounds-checked by default doesn't mean that the bounds-checking is necessarily in your final code:

https://rust.godbolt.org/z/er9Phcr3c

Yes, you still have the bounds check when constructing the slice, but that's fine.

And since it's probably slightly more common to iterate over the length of the vector anyway:

https://rust.godbolt.org/z/e5sdTb7vK