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:
Douman
2019-08-27 13:09:43 -07:00
committed by Carl Lerche
parent 79e4b2847f
commit b6cb346adf
16 changed files with 97 additions and 373 deletions
+3 -3
View File
@@ -9,7 +9,7 @@ fn collect_two_bufs() {
let a = Bytes::from(&b"hello"[..]);
let b = Bytes::from(&b"world"[..]);
let res: Vec<u8> = a.chain(b).collect();
let res = a.chain(b).to_bytes();
assert_eq!(res, &b"helloworld"[..]);
}
@@ -21,8 +21,8 @@ fn writing_chained() {
{
let mut buf = Chain::new(&mut a, &mut b);
for i in 0..128 {
buf.put(i as u8);
for i in 0u8..128 {
buf.put_u8(i);
}
}