Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::io::{Cursor, Read};
- fn main() {
- let v = [0, 1, 2, 3];
- let mut cur = Cursor::<&[u8]>::new(&v);
- let mut buf = Vec::with_capacity(4); // Length is known only at runtime
- unsafe { buf.set_len(4); }
- cur.read_exact(&mut buf).unwrap();
- println!("Buffer: {:?}", buf);
- }
Add Comment
Please, Sign In to add comment