Add IntoBuf trait

This commit is contained in:
Carl Lerche
2016-09-25 22:40:39 -07:00
parent b10992a5e8
commit 4ca7e0fabf
4 changed files with 67 additions and 2 deletions
+17
View File
@@ -0,0 +1,17 @@
extern crate bytes;
use bytes::{Buf, IntoBuf, Bytes};
pub fn dump<T>(data: &T) where
for<'a> &'a T: IntoBuf,
{
let mut dst: Vec<u8> = vec![];
data.into_buf().copy_to(&mut dst);
println!("GOT: {:?}", dst);
}
pub fn main() {
let b = Bytes::from_slice(b"hello world");
dump(&b);
dump(&b);
}