mirror of
https://github.com/tokio-rs/bytes.git
synced 2026-08-11 00:00:23 +02:00
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.
This commit is contained in:
+5
-13
@@ -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] {
|
||||
|
||||
Reference in New Issue
Block a user