mirror of
https://github.com/tokio-rs/bytes.git
synced 2026-08-13 00:00:32 +02:00
Add IntoBuf trait
This commit is contained in:
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user