From 659972d36d59be14b70a90e5bb51005582d886d7 Mon Sep 17 00:00:00 2001 From: Jack Wrenn Date: Thu, 28 Mar 2024 12:27:07 -0400 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Joshua Liebow-Feeser --- src/lib.rs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 35a09877d3..3ce8db0051 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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)> {