let mut buf = [0u8; 16]; // we want to fill this let mut window = buf.as_mut_slice(); while !window.is_empty() { match input.read(window) { Ok(n) => { let (_old, now) = window.split_at_mut(n); window = now; } Err(e) => ..., } }