Skip to content

Commit d9761b8

Browse files
authored
Rollup merge of #158282 - ArhanChaudhary:unchecked-subslice, r=tgross35,jhpratt
slice_split_once: bounds check optimization note Tracking issue: #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.
2 parents e5fdc41 + 5d07ed5 commit d9761b8

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

library/core/src/slice/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2530,6 +2530,7 @@ impl<T> [T] {
25302530
F: FnMut(&T) -> bool,
25312531
{
25322532
let index = self.iter().position(pred)?;
2533+
// Slice bounds checks optimized are away (as of June 2026)
25332534
Some((&self[..index], &self[index + 1..]))
25342535
}
25352536

@@ -2558,6 +2559,7 @@ impl<T> [T] {
25582559
F: FnMut(&T) -> bool,
25592560
{
25602561
let index = self.iter().rposition(pred)?;
2562+
// Slice bounds checks optimized are away (as of June 2026)
25612563
Some((&self[..index], &self[index + 1..]))
25622564
}
25632565

0 commit comments

Comments
 (0)