Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. use std::{io, mem};
  2. use std::io::Read;
  3.  
  4. fn fill(r: &mut Read, mut buf: &mut [u8]) -> io::Result<()> {
  5. while buf.len() > 0 {
  6. match r.read(buf).unwrap() {
  7. 0 => return Err(io::Error::new(io::ErrorKind::Other,
  8. "end of file reached")),
  9. n => buf = &mut mem::replace(&mut buf, &mut [])[n..],
  10. }
  11. }
  12. Ok(())
  13. }
  14.  
  15. fn main() {
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement