Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::{io, mem};
- use std::io::Read;
- fn fill(r: &mut Read, mut buf: &mut [u8]) -> io::Result<()> {
- while buf.len() > 0 {
- match r.read(buf).unwrap() {
- 0 => return Err(io::Error::new(io::ErrorKind::Other,
- "end of file reached")),
- n => buf = &mut mem::replace(&mut buf, &mut [])[n..],
- }
- }
- Ok(())
- }
- fn main() {
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement