Move "extra" methods to extension traits (#306)

This commit is contained in:
Sean McArthur
2019-10-31 09:39:58 -07:00
committed by GitHub
parent 2ac72333fa
commit 96268a80d4
11 changed files with 170 additions and 232 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
#![deny(warnings, rust_2018_idioms)]
use bytes::{Buf, BufMut, Bytes, BytesMut};
use bytes::buf::Chain;
use bytes::buf::BufExt;
use std::io::IoSlice;
#[test]
@@ -19,7 +19,7 @@ fn writing_chained() {
let mut b = BytesMut::with_capacity(64);
{
let mut buf = Chain::new(&mut a, &mut b);
let mut buf = (&mut a).chain(&mut b);
for i in 0u8..128 {
buf.put_u8(i);
+3 -3
View File
@@ -2,13 +2,13 @@
use std::io::{BufRead, Read};
use bytes::Buf;
use bytes::buf::{BufExt};
#[test]
fn read() {
let buf1 = &b"hello "[..];
let buf2 = &b"world"[..];
let buf = Buf::chain(buf1, buf2); // Disambiguate with Read::chain
let buf = BufExt::chain(buf1, buf2); // Disambiguate with Read::chain
let mut buffer = Vec::new();
buf.reader().read_to_end(&mut buffer).unwrap();
assert_eq!(b"hello world", &buffer[..]);
@@ -18,7 +18,7 @@ fn read() {
fn buf_read() {
let buf1 = &b"hell"[..];
let buf2 = &b"o\nworld"[..];
let mut reader = Buf::chain(buf1, buf2).reader();
let mut reader = BufExt::chain(buf1, buf2).reader();
let mut line = String::new();
reader.read_line(&mut line).unwrap();
assert_eq!("hello\n", &line);
+1 -1
View File
@@ -1,6 +1,6 @@
#![deny(warnings, rust_2018_idioms)]
use bytes::Buf;
use bytes::buf::{Buf, BufExt};
#[test]
fn long_take() {