Skip to content

Commit 4b337d2

Browse files
authored
Rollup merge of #72031 - Elinvynia:master, r=Mark-Simulacrum
Better documentation for io::Read::read() return value Aims to provide the clarity requested in #70360
2 parents 46d97c2 + 05fc7fa commit 4b337d2

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/libstd/io/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,11 @@ pub trait Read {
517517
/// reader will *always* no longer be able to produce bytes.
518518
/// 2. The buffer specified was 0 bytes in length.
519519
///
520+
/// It is not an error if the returned value `n` is smaller than the buffer size,
521+
/// even when the reader is not at the end of the stream yet.
522+
/// This may happen for example because fewer bytes are actually available right now
523+
/// (e. g. being close to end-of-file) or because read() was interrupted by a signal.
524+
///
520525
/// No guarantees are provided about the contents of `buf` when this
521526
/// function is called, implementations cannot rely on any property of the
522527
/// contents of `buf` being true. It is recommended that *implementations*

0 commit comments

Comments
 (0)