Skip to content

Commit 88031c3

Browse files
committed
revert split_at_mut
1 parent 0f639d7 commit 88031c3

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Diff for: library/core/src/str/mod.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -679,9 +679,12 @@ impl str {
679679
#[must_use]
680680
#[stable(feature = "str_split_at", since = "1.4.0")]
681681
pub fn split_at_mut(&mut self, mid: usize) -> (&mut str, &mut str) {
682-
match self.split_at_mut_checked(mid) {
683-
None => slice_error_fail(self, 0, mid),
684-
Some(pair) => pair,
682+
// is_char_boundary checks that the index is in [0, .len()]
683+
if self.is_char_boundary(mid) {
684+
// SAFETY: just checked that `mid` is on a char boundary.
685+
unsafe { self.split_at_mut_unchecked(mid) }
686+
} else {
687+
slice_error_fail(self, 0, mid)
685688
}
686689
}
687690

0 commit comments

Comments
 (0)