mirror of
https://github.com/tokio-rs/bytes.git
synced 2026-08-25 00:00:22 +02:00
Bytes::split_{off,to} should panic if at > len (#91)
This commit is contained in:
committed by
Carl Lerche
parent
b78bb3baaa
commit
627864187c
@@ -549,6 +549,8 @@ impl Bytes {
|
||||
///
|
||||
/// Panics if `at > len`
|
||||
pub fn split_off(&mut self, at: usize) -> Bytes {
|
||||
assert!(at <= self.len());
|
||||
|
||||
if at == self.len() {
|
||||
return Bytes::new();
|
||||
}
|
||||
@@ -588,6 +590,8 @@ impl Bytes {
|
||||
///
|
||||
/// Panics if `at > len`
|
||||
pub fn split_to(&mut self, at: usize) -> Bytes {
|
||||
assert!(at <= self.len());
|
||||
|
||||
if at == self.len() {
|
||||
return mem::replace(self, Bytes::new());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user