We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
assume(idx < self.len())
[T]::get_unchecked
1 parent 341abd1 commit 0cb2767Copy full SHA for 0cb2767
core/src/slice/index.rs
@@ -233,7 +233,10 @@ unsafe impl<T> SliceIndex<[T]> for usize {
233
// cannot be longer than `isize::MAX`. They also guarantee that
234
// `self` is in bounds of `slice` so `self` cannot overflow an `isize`,
235
// so the call to `add` is safe.
236
- unsafe { slice.as_ptr().add(self) }
+ unsafe {
237
+ crate::intrinsics::assume(self < slice.len());
238
+ slice.as_ptr().add(self)
239
+ }
240
}
241
242
#[inline]
0 commit comments