Skip to content

Commit 55dfea8

Browse files
nanpuyuecarllerche
authored andcommitted
Impl FromIterator<&'a u8> for BytesMut/Bytes (#244)
1 parent f3b363a commit 55dfea8

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/bytes.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -926,6 +926,18 @@ impl FromIterator<u8> for Bytes {
926926
}
927927
}
928928

929+
impl<'a> FromIterator<&'a u8> for BytesMut {
930+
fn from_iter<T: IntoIterator<Item = &'a u8>>(into_iter: T) -> Self {
931+
BytesMut::from_iter(into_iter.into_iter().map(|b| *b))
932+
}
933+
}
934+
935+
impl<'a> FromIterator<&'a u8> for Bytes {
936+
fn from_iter<T: IntoIterator<Item = &'a u8>>(into_iter: T) -> Self {
937+
BytesMut::from_iter(into_iter).freeze()
938+
}
939+
}
940+
929941
impl PartialEq for Bytes {
930942
fn eq(&self, other: &Bytes) -> bool {
931943
self.inner.as_ref() == other.inner.as_ref()

0 commit comments

Comments
 (0)