Skip to content

Commit

Permalink
Fix Read impl for Vec<u8>
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomasdezeeuw committed Mar 22, 2024
1 parent cbfcfcc commit a431e62
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions rt/src/io/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ impl Read for &[u8] {
impl Read for Vec<u8> {
async fn read<B: BufMut>(&mut self, mut buf: B) -> io::Result<B> {
let read = buf.extend_from_slice(self);
drop(self.drain(read..));
drop(self.drain(..read));
Ok(buf)
}

Expand All @@ -176,7 +176,7 @@ impl Read for Vec<u8> {
Err(io::ErrorKind::UnexpectedEof.into())
} else {
let read = buf.extend_from_slice(self);
drop(self.drain(read..));
drop(self.drain(..read));
Ok(buf)
}
}
Expand All @@ -190,7 +190,7 @@ impl Read for Vec<u8> {
mut bufs: B,
) -> io::Result<B> {
let read = bufs.extend_from_slice(self);
drop(self.drain(read..));
drop(self.drain(..read));
Ok(bufs)
}

Expand All @@ -207,7 +207,7 @@ impl Read for Vec<u8> {
Err(io::ErrorKind::UnexpectedEof.into())
} else {
let read = bufs.extend_from_slice(self);
drop(self.drain(read..));
drop(self.drain(..read));
Ok(bufs)
}
}
Expand Down

0 comments on commit a431e62

Please sign in to comment.