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.
1 parent febca57 commit d89af64Copy full SHA for d89af64
library/core/src/str/mod.rs
@@ -678,12 +678,9 @@ impl str {
678
#[must_use]
679
#[stable(feature = "str_split_at", since = "1.4.0")]
680
pub fn split_at_mut(&mut self, mid: usize) -> (&mut str, &mut str) {
681
- // is_char_boundary checks that the index is in [0, .len()]
682
- if self.is_char_boundary(mid) {
683
- // SAFETY: just checked that `mid` is on a char boundary.
684
- unsafe { self.split_at_mut_unchecked(mid) }
685
- } else {
686
- slice_error_fail(self, 0, mid)
+ match self.split_at_mut_checked(mid) {
+ None => slice_error_fail(self, 0, mid),
+ Some(pair) => pair,
687
}
688
689
0 commit comments