diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-03-10 22:16:42 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-03-10 22:16:42 +0100 |
| commit | 0c73b2db41f9e472e65300d3fe2864005be0c46b (patch) | |
| tree | 99015ad25a92f19b585607d8dfcccbd2ba8e3b9a /library/std/src | |
| parent | 217d00494fdb6f5bb20d77f9a15855d0750ecd96 (diff) | |
| parent | 93049bece079f7cedb781ab293e93242592b4957 (diff) | |
| download | rust-0c73b2db41f9e472e65300d3fe2864005be0c46b.tar.gz rust-0c73b2db41f9e472e65300d3fe2864005be0c46b.zip | |
Rollup merge of #122276 - RalfJung:io-read, r=Nilstrieb
io::Read trait: make it more clear when we are adressing implementations vs callers Inspired by [this](https://github.com/rust-lang/rust/issues/72186#issuecomment-1987076295) comment. For some reason we only have that `buf` warning in `read` and `read_exact`, even though it affects a bunch of other functions of this trait as well. It doesn't seem worth copy-pasting the same text everywhere though so I did not change this.
Diffstat (limited to 'library/std/src')
| -rw-r--r-- | library/std/src/io/mod.rs | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index 9a4a2301b6f..10bf9c51d16 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -692,10 +692,9 @@ pub trait Read { /// Callers have to ensure that no unchecked out-of-bounds accesses are possible even if /// `n > buf.len()`. /// - /// No guarantees are provided about the contents of `buf` when this - /// function is called, so implementations cannot rely on any property of the - /// contents of `buf` being true. It is recommended that *implementations* - /// only write data to `buf` instead of reading its contents. + /// *Implementations* of this method can make no assumptions about the contents of `buf` when + /// this function is called. It is recommended that implementations only write data to `buf` + /// instead of reading its contents. /// /// Correspondingly, however, *callers* of this method in unsafe code must not assume /// any guarantees about how the implementation uses `buf`. The trait is safe to implement, @@ -901,12 +900,10 @@ pub trait Read { /// This function reads as many bytes as necessary to completely fill the /// specified buffer `buf`. /// - /// No guarantees are provided about the contents of `buf` when this - /// function is called, so implementations cannot rely on any property of the - /// contents of `buf` being true. It is recommended that implementations - /// only write data to `buf` instead of reading its contents. The - /// documentation on [`read`] has a more detailed explanation on this - /// subject. + /// *Implementations* of this method can make no assumptions about the contents of `buf` when + /// this function is called. It is recommended that implementations only write data to `buf` + /// instead of reading its contents. The documentation on [`read`] has a more detailed + /// explanation of this subject. /// /// # Errors /// |
