This commit is contained in:
Mathieu Amiot 2018-07-11 07:34:51 +00:00 committed by GitHub
commit 74a6b03bb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 3 deletions

View File

@ -405,9 +405,8 @@ impl<T: Read> Read for IoWrapper<T> {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> { fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
if let Some(mut bytes) = self.unread.take() { if let Some(mut bytes) = self.unread.take() {
let size = cmp::min(buf.len(), bytes.len()); let size = cmp::min(buf.len(), bytes.len());
buf[..size].copy_from_slice(&bytes[..size]); buf[..size].copy_from_slice(&bytes.split_to(size));
if bytes.len() > size { if bytes.len() > 0 {
bytes.split_to(size);
self.unread = Some(bytes); self.unread = Some(bytes);
} }
Ok(size) Ok(size)