about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2020-05-09 03:10:16 +0200
committerGitHub <noreply@github.com>2020-05-09 03:10:16 +0200
commit4b337d2bf6204f574a9bece504df4de7cb7ed032 (patch)
tree2e8aad8b2b1cd2cdb02f65a0b5bb645e96ee5b71 /src/libstd
parent46d97c21cfede70164c7b8f1d797e9d75c7e0735 (diff)
parent05fc7faacb7c33eaad6614f62a7d560b0d2660a5 (diff)
downloadrust-4b337d2bf6204f574a9bece504df4de7cb7ed032.tar.gz
rust-4b337d2bf6204f574a9bece504df4de7cb7ed032.zip
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
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/io/mod.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs
index 36c6aa620d5..ebe6d09023f 100644
--- a/src/libstd/io/mod.rs
+++ b/src/libstd/io/mod.rs
@@ -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*