Skip to content

Commit

Permalink
Rollup merge of rust-lang#120523 - a1phyr:improve_read_buf_exact, r=t…
Browse files Browse the repository at this point in the history
…he8472

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

- Use `const_io_error` instead of `Error::new`
- Use the same message as `read_exact`
  • Loading branch information
matthiaskrgr authored Jan 31, 2024
2 parents 0dd87c6 + a158fb3 commit 90f9b15
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 90f9b15

Please sign in to comment.