Impl FromIterator<&'a u8> for BytesMut/Bytes (#244)

This commit is contained in:
南浦月
2019-01-30 11:05:15 -08:00
committed by Carl Lerche
parent f3b363a385
commit 55dfea8c18
+12
View File
@@ -926,6 +926,18 @@ impl FromIterator<u8> for Bytes {
}
}
impl<'a> FromIterator<&'a u8> for BytesMut {
fn from_iter<T: IntoIterator<Item = &'a u8>>(into_iter: T) -> Self {
BytesMut::from_iter(into_iter.into_iter().map(|b| *b))
}
}
impl<'a> FromIterator<&'a u8> for Bytes {
fn from_iter<T: IntoIterator<Item = &'a u8>>(into_iter: T) -> Self {
BytesMut::from_iter(into_iter).freeze()
}
}
impl PartialEq for Bytes {
fn eq(&self, other: &Bytes) -> bool {
self.inner.as_ref() == other.inner.as_ref()