parent
80c091958f
commit
321fab4337
1 changed files with 11 additions and 0 deletions
|
|
@ -188,6 +188,13 @@ impl Read for Repeat {
|
|||
Ok(buf.len())
|
||||
}
|
||||
|
||||
fn read_exact(&mut self, buf: &mut [u8]) -> io::Result<()> {
|
||||
for slot in &mut *buf {
|
||||
*slot = self.byte;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn read_buf(&mut self, mut buf: BorrowedCursor<'_>) -> io::Result<()> {
|
||||
// SAFETY: No uninit bytes are being written
|
||||
for slot in unsafe { buf.as_mut() } {
|
||||
|
|
@ -204,6 +211,10 @@ impl Read for Repeat {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn read_buf_exact(&mut self, buf: BorrowedCursor<'_>) -> io::Result<()> {
|
||||
self.read_buf(buf)
|
||||
}
|
||||
|
||||
/// This function is not supported by `io::Repeat`, because there's no end of its data
|
||||
fn read_to_end(&mut self, _: &mut Vec<u8>) -> io::Result<usize> {
|
||||
Err(io::Error::from(io::ErrorKind::OutOfMemory))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue