diff --git a/src/bytes_mut.rs b/src/bytes_mut.rs index 88d596cf6..155d686fb 100644 --- a/src/bytes_mut.rs +++ b/src/bytes_mut.rs @@ -888,13 +888,7 @@ impl BytesMut { // new start and updating the `len` field to reflect the new length // of the view. self.ptr = vptr(self.ptr.as_ptr().add(start)); - - if self.len >= start { - self.len -= start; - } else { - self.len = 0; - } - + self.len = self.len.checked_sub(start).unwrap_or(0); self.cap -= start; }