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
+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);