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 900e6fa commit dd8820fCopy full SHA for dd8820f
library/core/src/str/mod.rs
@@ -772,9 +772,18 @@ impl str {
772
///
773
/// The caller must ensure that `mid` is a valid byte offset from the start
774
/// of the string and falls on the boundary of a UTF-8 code point.
775
+ #[inline]
776
+ #[must_use]
777
unsafe const fn split_at_mut_unchecked(&mut self, mid: usize) -> (&mut str, &mut str) {
778
let len = self.len();
779
let ptr = self.as_mut_ptr();
780
+
781
+ assert_unsafe_precondition!(
782
+ check_library_ub,
783
+ "slice::split_at_mut_unchecked requires the index to be within the slice",
784
+ (mid: usize = mid, len: usize = len) => mid <= len,
785
+ );
786
787
// SAFETY: caller guarantees `mid` is on a char boundary.
788
unsafe {
789
(
0 commit comments