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
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