rust/library/std/src/io
Dylan DPC db4a97c4cb
Rollup merge of #82892 - jix:clarify-read-read, r=joshtriplett
Clarify docs for Read::read's return value

Right now the docs for `Read::read`'s return value are phrased in a way that makes it easy for the reader to assume that the return value is never larger than the passed buffer. This PR clarifies that this is a requirement for implementations of the trait, but that callers have to expect a buggy yet safe implementation failing to do so, especially if unchecked accesses to the buffer are done afterwards.

I fell into this trap recently, and when I noticed, I looked at the docs again and had the feeling that I might not have been the first one to miss this.

The same issue of trusting the return value of `read` was also present in std itself for about 2.5 years and only fixed recently, see #80895.

I hope that clarifying the docs might help others to avoid this issue.
2021-03-19 15:03:22 +01:00
..
buffered Rollup merge of #82728 - calebsander:refactor/bufreader-buf, r=m-ou-se 2021-03-05 10:57:20 +01:00
cursor Make some std::io functions const 2020-11-06 17:48:26 +01:00
error std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
impls std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
stdio std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
util specialize io::copy to use the memory of the writer if it is a BufWriter 2021-01-31 14:58:03 +01:00
copy.rs library: Normalize safety-for-unsafe-block comments 2021-02-24 06:13:42 +01:00
cursor.rs Add tracking issue 2020-11-06 18:04:52 +01:00
error.rs std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
impls.rs Generalize Write impl for Vec<u8> to Vec<u8, A> 2021-03-07 16:22:53 +01:00
mod.rs Clarify docs for Read::read's return value 2021-03-18 22:52:46 +01:00
prelude.rs Use heading for std::prelude and not io::prelude 2021-01-05 17:52:24 -08:00
stdio.rs Add missing "see its documentation for more" stdio 2021-02-22 18:48:32 +08:00
tests.rs Add tests for SizeHint implementations 2021-01-31 08:34:42 -05:00
util.rs Fix line length format 2021-01-31 08:52:57 -05:00