Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
mina86 committed Jan 10, 2024
1 parent 037466e commit 967bfdd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
9 changes: 5 additions & 4 deletions library/core/src/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1832,7 +1832,7 @@ impl<T> [T] {
///
/// # Panics
///
/// Panics if `mid > len`. For non-panicking alternative see
/// Panics if `mid > len`. For a non-panicking alternative see
/// [`split_at_checked`](slice::split_at_checked).
///
/// # Examples
Expand Down Expand Up @@ -1879,7 +1879,7 @@ impl<T> [T] {
///
/// # Panics
///
/// Panics if `mid > len`. For non-panicking alternative see
/// Panics if `mid > len`. For a non-panicking alternative see
/// [`split_at_mut_checked`](slice::split_at_mut_checked).
///
/// # Examples
Expand Down Expand Up @@ -2021,7 +2021,7 @@ impl<T> [T] {
unsafe { (from_raw_parts_mut(ptr, mid), from_raw_parts_mut(ptr.add(mid), len - mid)) }
}

/// Divides one slice into two at an index returning `None` if slice is too
/// Divides one slice into two at an index returning, `None` if slice is too
/// short.
///
/// The first will contain all indices from `[0, mid)` (excluding
Expand Down Expand Up @@ -2072,7 +2072,8 @@ impl<T> [T] {
}
}

/// Divides one mutable slice into two at an index.
/// Divides one mutable slice into two at an index, returning `None` if
/// slice is too short.
///
/// The first will contain all indices from `[0, mid)` (excluding
/// the index `mid` itself) and the second will contain all
Expand Down
9 changes: 6 additions & 3 deletions library/core/src/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,10 @@ impl str {
#[must_use]
#[stable(feature = "str_split_at", since = "1.4.0")]
pub fn split_at(&self, mid: usize) -> (&str, &str) {
self.split_at_checked(mid).unwrap_or_else(|| slice_error_fail(self, 0, mid))
match self.split_at_checked(mid) {
None => slice_error_fail(self, 0, mid),
Some(pair) => pair,
}
}

/// Divide one mutable string slice into two at an index.
Expand Down Expand Up @@ -792,8 +795,8 @@ impl str {
///
/// # Safety
///
/// The caller must ensure `mid` is a byte offset at a UTF-8 character
/// boundary.
/// The caller must ensure that `mid` is a valid byte offset from the start
/// of the string and falls on the boundary of a UTF-8 code point.
unsafe fn split_at_mut_unchecked(&mut self, mid: usize) -> (&mut str, &mut str) {
let len = self.len();
let ptr = self.as_mut_ptr();
Expand Down

0 comments on commit 967bfdd

Please sign in to comment.