From b6cb346adfaae89bce44bfa337652e6d218d38c4 Mon Sep 17 00:00:00 2001 From: Douman Date: Tue, 27 Aug 2019 22:09:43 +0200 Subject: 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. --- src/bytes.rs | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) (limited to 'src/bytes.rs') 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 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] { -- cgit v1.2.3