mirror of
https://github.com/tokio-rs/bytes.git
synced 2026-08-12 00:00:14 +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:
+3
-7
@@ -1,4 +1,4 @@
|
||||
use super::{IntoBuf, Writer};
|
||||
use super::{Writer};
|
||||
|
||||
use std::{mem, cmp, io::IoSliceMut, ptr, usize};
|
||||
|
||||
@@ -208,7 +208,7 @@ pub trait BufMut {
|
||||
///
|
||||
/// let mut buf = vec![];
|
||||
///
|
||||
/// buf.put(b'h');
|
||||
/// buf.put_u8(b'h');
|
||||
/// buf.put(&b"ello"[..]);
|
||||
/// buf.put(" world");
|
||||
///
|
||||
@@ -218,11 +218,7 @@ pub trait BufMut {
|
||||
/// # Panics
|
||||
///
|
||||
/// Panics if `self` does not have enough capacity to contain `src`.
|
||||
fn put<T: IntoBuf>(&mut self, src: T) where Self: Sized {
|
||||
use super::Buf;
|
||||
|
||||
let mut src = src.into_buf();
|
||||
|
||||
fn put<T: super::Buf>(&mut self, mut src: T) where Self: Sized {
|
||||
assert!(self.remaining_mut() >= src.remaining());
|
||||
|
||||
while src.has_remaining() {
|
||||
|
||||
Reference in New Issue
Block a user