Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Joshua Liebow-Feeser <[email protected]>
  • Loading branch information
jswrenn and joshlf committed Mar 28, 2024
1 parent 4bac39f commit 659972d
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5701,20 +5701,25 @@ pub unsafe trait SplitByteSlice: ByteSlice {
}
}

/// Splits the slice at the midpoint, with minimal runtime checks.
/// Splits the slice at the midpoint, possibly omitting bounds checks.
///
/// `x.split_at_unchecked(mid)` returns `x[..mid]` and `x[mid..]`.
///
/// # Safety
///
/// `mid` must not be greater than `x.deref().len()`
/// `mid` must not be greater than `x.deref().len()`.
///
/// # Panics
///
/// Some implementations may panic instead of exhibiting undefined
/// behavior when `mid` is greater than `x.deref().len()`.
#[must_use]
unsafe fn split_at_unchecked(self, mid: usize) -> (Self, Self);

/// Attempts to split the slice at the midpoint.
///
/// `x.try_split_at(mid)` returns `Some((x[..mid], x[mid..]))`, if `mid <=
/// x.deref().len()`; otherwise `None`.
/// `x.try_split_at(mid)` returns `Some((x[..mid], x[mid..]))` if `mid <=
/// x.deref().len()` and otherwise returns `None`.
#[must_use]
#[inline]
fn try_split_at(self, mid: usize) -> Option<(Self, Self)> {
Expand Down

0 comments on commit 659972d

Please sign in to comment.