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:
Benoît du Garreau 2024-01-31 11:05:41 +01:00
parent cdaa12e3df
commit a158fb33ef

View File

@ -994,7 +994,10 @@ pub trait Read {
}
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"
));
}
}