aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bytes.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/bytes.rs b/src/bytes.rs
index c3240ce..908cee9 100644
--- a/src/bytes.rs
+++ b/src/bytes.rs
@@ -385,13 +385,6 @@ impl Bytes {
/// Panics if `at > len`.
#[must_use = "consider Bytes::truncate if you don't need the other half"]
pub fn split_off(&mut self, at: usize) -> Self {
- assert!(
- at <= self.len(),
- "split_off out of bounds: {:?} <= {:?}",
- at,
- self.len(),
- );
-
if at == self.len() {
return Bytes::new();
}
@@ -400,6 +393,13 @@ impl Bytes {
return mem::replace(self, Bytes::new());
}
+ assert!(
+ at <= self.len(),
+ "split_off out of bounds: {:?} <= {:?}",
+ at,
+ self.len(),
+ );
+
let mut ret = self.clone();
self.len = at;