Skip to content

Commit

Permalink
Impl FromIterator<&'a u8> for BytesMut/Bytes (#244)
Browse files Browse the repository at this point in the history
  • Loading branch information
nanpuyue authored and carllerche committed Jan 30, 2019
1 parent f3b363a commit 55dfea8
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/bytes.rs
Expand Up @@ -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()
Expand Down

0 comments on commit 55dfea8

Please sign in to comment.