Slight improvement to BytesMut
This commit is contained in:
parent
4f0bce5fca
commit
f9f5acb73a
1 changed files with 8 additions and 5 deletions
13
src/utils.rs
13
src/utils.rs
|
@ -90,15 +90,18 @@ impl<'a> BytesMut<'a> {
|
||||||
*first = v;
|
*first = v;
|
||||||
Self(tail)
|
Self(tail)
|
||||||
} else {
|
} else {
|
||||||
cold();
|
unreachable!()
|
||||||
panic!();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn write_many(self, v: &[u8]) -> Self {
|
pub fn write_many(self, v: &[u8]) -> Self {
|
||||||
let (head, tail) = self.0.split_at_mut(v.len());
|
if v.len() <= self.0.len() {
|
||||||
head.copy_from_slice(v);
|
let (head, tail) = self.0.split_at_mut(v.len());
|
||||||
Self(tail)
|
head.copy_from_slice(v);
|
||||||
|
Self(tail)
|
||||||
|
} else {
|
||||||
|
unreachable!()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue