Slight improvement to BytesMut

This commit is contained in:
Ivan Smirnov 2022-01-03 18:31:06 +03:00
parent 4f0bce5fca
commit f9f5acb73a

View file

@ -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 {
if v.len() <= self.0.len() {
let (head, tail) = self.0.split_at_mut(v.len()); let (head, tail) = self.0.split_at_mut(v.len());
head.copy_from_slice(v); head.copy_from_slice(v);
Self(tail) Self(tail)
} else {
unreachable!()
}
} }
} }