diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-06-27 23:01:04 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-06-27 23:01:04 +0200 |
| commit | 36b26e9bacb7fdb2b8a0a908878f621ed4f9a1f1 (patch) | |
| tree | 25a6e194392e943ffd749ed151b8a57e7da8442c /src/libstd | |
| parent | 1c7d311fdcf704286fb1a9ce1b36a7655924ce50 (diff) | |
| parent | 390f717a0af5851271792da9ff235c95f3db2556 (diff) | |
| download | rust-36b26e9bacb7fdb2b8a0a908878f621ed4f9a1f1.tar.gz rust-36b26e9bacb7fdb2b8a0a908878f621ed4f9a1f1.zip | |
Rollup merge of #62102 - RalfJung:read, r=Centril
call out explicitly that general read needs to be called with an initialized buffer
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/io/mod.rs | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 917199f8ea8..3d0568c16cd 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, *callers* of this method may not assume any guarantees + /// about how the implementation uses `buf`. The trait is safe to implement, + // so it is possible that the code that's supposed to write to the buffer might also read + // from it. 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 |
