feat: update bytes

This commit is contained in:
2022-03-25 23:13:08 +08:00
parent 8fa4284e6c
commit f104c9dec9

View File

@@ -3,7 +3,16 @@ use bytes::{BytesMut, BufMut};
fn main() {
let mut buf = BytesMut::new();
buf.put_u8(0x20);
buf.put_u16(0x1234);
buf.put_u8(0x20);
buf.put_u16_le(0x1234);
buf.put(&b"hello world"[..]);
println!("{:?}", buf);
println!("{:?}", &buf);
println!("{:x?}", &buf[..]);
let mut buf2 = BytesMut::with_capacity(8);
println!("{:x?}", &buf2[..]);
buf2.resize(8, 0x00);
println!("{:x?}", &buf2[..]);
}