Bytes::split_{off,to} should panic if at > len (#91)

This commit is contained in:
Stepan Koltsov
2017-03-28 12:38:48 -07:00
committed by Carl Lerche
parent b78bb3baaa
commit 627864187c
2 changed files with 26 additions and 0 deletions
+4
View File
@@ -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());
}