Rollup merge of #120523 - a1phyr:improve_read_buf_exact, r=the8472

Improve `io::Read::read_buf_exact` error case

- Use `const_io_error` instead of `Error::new`
- Use the same message as `read_exact`
This commit is contained in:
Matthias Krüger 2024-02-03 22:25:15 +01:00 committed by GitHub
commit a3ea64719b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -994,7 +994,10 @@ fn read_buf_exact(&mut self, mut cursor: BorrowedCursor<'_>) -> Result<()> {
}
if cursor.written() == prev_written {
return Err(Error::new(ErrorKind::UnexpectedEof, "failed to fill buffer"));
return Err(error::const_io_error!(
ErrorKind::UnexpectedEof,
"failed to fill whole buffer"
));
}
}