diff options
author | 2019-08-27 22:09:43 +0200 | |
---|---|---|
committer | 2019-08-27 13:09:43 -0700 | |
commit | b6cb346adfaae89bce44bfa337652e6d218d38c4 (patch) | |
tree | 0e6cb36b1db4ece480554bce0f2f0ab307013931 /src/bytes.rs | |
parent | 79e4b2847f27137faaf149d116a352cbeae47fd1 (diff) | |
download | bytes-b6cb346adfaae89bce44bfa337652e6d218d38c4.tar.gz bytes-b6cb346adfaae89bce44bfa337652e6d218d38c4.tar.zst bytes-b6cb346adfaae89bce44bfa337652e6d218d38c4.zip |
Remove IntoBuf/FromBuf (#288)
As consequence Buf::collect is removed as well, which is replaced with `Buf::into_bytes`. The advantage of `Buf::into_bytes` is that it can be optimized in cases where converting a `T: Buf` into a `Bytes` instance is efficient.
Diffstat (limited to 'src/bytes.rs')
-rw-r--r-- | src/bytes.rs | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/src/bytes.rs b/src/bytes.rs index 3f8b23a..99022f0 100644 --- a/src/bytes.rs +++ b/src/bytes.rs @@ -1,4 +1,4 @@ -use crate::{Buf, BufMut, IntoBuf}; +use crate::{Buf, BufMut}; use crate::buf::IntoIter; use crate::debug; @@ -133,8 +133,8 @@ pub struct Bytes { /// /// let mut buf = BytesMut::with_capacity(64); /// -/// buf.put(b'h'); -/// buf.put(b'e'); +/// buf.put_u8(b'h'); +/// buf.put_u8(b'e'); /// buf.put("llo"); /// /// assert_eq!(&buf[..], b"hello"); @@ -842,7 +842,7 @@ impl Bytes { /// # Examples /// /// ``` - /// use bytes::{Buf, IntoBuf, Bytes}; + /// use bytes::{Buf, Bytes}; /// /// let buf = Bytes::from(&b"abc"[..]); /// let mut iter = buf.iter(); @@ -943,7 +943,7 @@ impl FromIterator<u8> for BytesMut { for i in iter { out.reserve(1); - out.put(i); + out.put_u8(i); } out @@ -1602,14 +1602,6 @@ impl BufMut for BytesMut { } } -impl<'a> IntoBuf for &'a BytesMut { - type Buf = &'a [u8]; - - fn into_buf(self) -> Self::Buf { - self.as_ref() - } -} - impl AsRef<[u8]> for BytesMut { #[inline] fn as_ref(&self) -> &[u8] { |