Skip to content

Commit

Permalink
Improve io::Read::read_buf_exact error case
Browse files Browse the repository at this point in the history
- Use `const_io_error` instead of `Error::new`
- Use the same message as `read_exact`
  • Loading branch information
a1phyr committed Jan 31, 2024
1 parent cdaa12e commit a158fb3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion library/std/src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
));
}
}

Expand Down

0 comments on commit a158fb3

Please sign in to comment.