Skip to content

Commit ca4989e

Browse files
committed
SplitInternal: always set finished in get_end
1 parent c5351ad commit ca4989e

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

library/core/src/str/iter.rs

+8-7
Original file line numberDiff line numberDiff line change
@@ -585,16 +585,17 @@ where
585585
impl<'a, P: Pattern<'a>> SplitInternal<'a, P> {
586586
#[inline]
587587
fn get_end(&mut self) -> Option<&'a str> {
588-
if !self.finished && (self.allow_trailing_empty || self.end - self.start > 0) {
588+
if !self.finished {
589589
self.finished = true;
590-
// SAFETY: `self.start` and `self.end` always lie on unicode boundaries.
591-
unsafe {
592-
let string = self.matcher.haystack().get_unchecked(self.start..self.end);
593-
Some(string)
590+
591+
if self.allow_trailing_empty || self.end - self.start > 0 {
592+
// SAFETY: `self.start` and `self.end` always lie on unicode boundaries.
593+
let string = unsafe { self.matcher.haystack().get_unchecked(self.start..self.end) };
594+
return Some(string);
594595
}
595-
} else {
596-
None
597596
}
597+
598+
None
598599
}
599600

600601
#[inline]

0 commit comments

Comments
 (0)