mirror of
https://github.com/tokio-rs/bytes.git
synced 2026-08-18 00:00:12 +02:00
Provide Take decorator that limits Buf size
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
use bytes::*;
|
||||
use std::io::{Cursor, Read};
|
||||
|
||||
#[test]
|
||||
pub fn test_take_from_buf() {
|
||||
let mut buf = Take::new(Cursor::new(b"hello world".to_vec()), 5);
|
||||
let mut res = vec![];
|
||||
|
||||
buf.read_to_end(&mut res);
|
||||
|
||||
assert_eq!(&res, b"hello");
|
||||
}
|
||||
Reference in New Issue
Block a user