Rollup merge of #158282 - ArhanChaudhary:unchecked-subslice, r=tgross35,jhpratt slice_split_once: bounds check optimization note Tracking issue: https://github.com/rust-lang/rust/issues/112811 ~~Use unchecked sub-slicing operations for `<T>::split_once` and `<T>::rsplit_once`.~~ Note that unchecked sub-slicing operations are equivalent to the current checked sub-slicing operations.
diff --git a/library/core/src/slice/mod.rs b/library/core/src/slice/mod.rs index 9b077f1..7ab476e 100644 --- a/library/core/src/slice/mod.rs +++ b/library/core/src/slice/mod.rs
@@ -2530,6 +2530,7 @@ pub fn split_once<F>(&self, pred: F) -> Option<(&[T], &[T])> F: FnMut(&T) -> bool, { let index = self.iter().position(pred)?; + // Slice bounds checks optimized are away (as of June 2026) Some((&self[..index], &self[index + 1..])) } @@ -2558,6 +2559,7 @@ pub fn rsplit_once<F>(&self, pred: F) -> Option<(&[T], &[T])> F: FnMut(&T) -> bool, { let index = self.iter().rposition(pred)?; + // Slice bounds checks optimized are away (as of June 2026) Some((&self[..index], &self[index + 1..])) }