about summary refs log tree commit diff
path: root/src/libstd/io
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2019-06-24 22:58:53 +0200
committerRalf Jung <post@ralfj.de>2019-06-24 22:58:53 +0200
commit1c12b1be330dd9c3de0b4fe599686d7c0c45e720 (patch)
tree9309e6b417a353a3fc009b637006196ba554ae6d /src/libstd/io
parent7e08576e4276a97b523c25bfd196d419c39c7b87 (diff)
downloadrust-1c12b1be330dd9c3de0b4fe599686d7c0c45e720.tar.gz
rust-1c12b1be330dd9c3de0b4fe599686d7c0c45e720.zip
call out explicitly that general read needs to be called with an initialized buffer
Diffstat (limited to 'src/libstd/io')
-rw-r--r--src/libstd/io/mod.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs
index 917199f8ea8..7fba844897f 100644
--- a/src/libstd/io/mod.rs
+++ b/src/libstd/io/mod.rs
@@ -506,9 +506,18 @@ pub trait Read {
     ///
     /// 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
+    /// contents of `buf` being true. It is recommended that *implementations*
     /// only write data to `buf` instead of reading its contents.
     ///
+    /// Correspondingly, however, *users* of this trait may not assume any guarantees
+    /// about how the implementation uses `buf`. The trait is safe to implement,
+    /// so it is perfectly possible that the implementation might inspect that data.
+    /// As a caller, it is your responsibility to make sure that `buf` is initialized
+    /// before calling `read`. Calling `read` with an uninitialized `buf` (of the kind one
+    /// obtains via [`MaybeUninit<T>`]) is not safe, and can lead to undefined behavior.
+    ///
+    /// [`MaybeUninit<T>`]: ../mem/union.MaybeUninit.html
+    ///
     /// # Errors
     ///
     /// If this function encounters any form of I/O or other error, an error