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
This commit is contained in:
Dylan DPC 2020-05-09 03:10:16 +02:00 committed by GitHub
commit 4b337d2bf6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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