Add vectored support to Buf and BufMut

This commit is contained in:
Carl Lerche
2017-03-01 13:18:29 -08:00
parent 4462056e26
commit bb9bf7ee3e
7 changed files with 103 additions and 1 deletions
+14
View File
@@ -1,7 +1,9 @@
extern crate bytes;
extern crate byteorder;
extern crate iovec;
use bytes::{BufMut, BytesMut};
use iovec::IoVec;
use std::usize;
use std::fmt::Write;
@@ -56,3 +58,15 @@ fn test_clone() {
buf.write_str(" of our emergecy broadcast system").unwrap();
assert!(buf != buf2);
}
#[test]
fn test_bufs_vec_mut() {
use std::mem;
let mut buf = BytesMut::from(&b"hello world"[..]);
unsafe {
let mut dst: [&mut IoVec; 2] = mem::zeroed();
assert_eq!(1, buf.bytes_vec_mut(&mut dst[..]));
}
}