rust/library/std/src/io
Matthias Krüger 876f00a655
Rollup merge of #107200 - mina86:c, r=Amanieu
io: soften ‘at most one write attempt’ requirement in io::Write::write

At the moment, documentation of std::io::Write::write indicates that
call to it ‘represents at most one attempt to write to any wrapped
object’.  It seems that such wording was put there to contrast it with
pre-1.0 interface which attempted to write all the data (it has since
been changed in [RFC 517]).

However, the requirement puts unnecessary constraints and may
complicate adaptors which perform non-trivial transformations on the
data.  For example, they may maintain an internal buffer which needs
to be written out before the write method accepts more data.  It might
be natural to code the method such that it flushes the buffer and then
grabs another chunk of user data.  With the current wording in the
documentation, the adaptor would be forced to return Ok(0).

This commit softens the wording such that implementations can choose
code structure which makes most sense for their particular use case.

While at it, elaborate on the meaning of `Ok(0)` return pointing out
that the write_all methods interprets it as an error.

[RFC 517]: https://rust-lang.github.io/rfcs/0517-io-os-reform.html
2023-06-18 08:06:41 +02:00
..
buffered Extend io::copy buffer reuse to BufReader too 2023-06-17 11:07:04 +02:00
copy Extend io::copy buffer reuse to BufReader too 2023-06-17 11:07:04 +02:00
cursor attempt to optimise vectored write 2022-06-26 17:15:31 +01:00
error std: add type alias for raw OS errors 2023-01-31 17:23:35 +01:00
impls std: move "mod tests/benches" to separate files 2020-08-31 02:56:59 +00:00
readbuf Spelling library/ 2023-04-26 02:10:22 -04:00
stdio Make default stdio lock() return 'static handles 2022-02-13 10:23:16 -05:00
util Extend io::copy buffer reuse to BufReader too 2023-06-17 11:07:04 +02:00
copy.rs Extend io::copy buffer reuse to BufReader too 2023-06-17 11:07:04 +02:00
cursor.rs Rollup merge of #98651 - mattfbacon:master, r=ChrisDenton 2023-03-27 08:46:51 +02:00
error.rs remove some unneeded imports 2023-04-12 19:27:18 +02:00
impls.rs Rollup merge of #110633 - scottmcm:more-take, r=thomcc 2023-04-21 20:35:29 +05:30
mod.rs Rollup merge of #107200 - mina86:c, r=Amanieu 2023-06-18 08:06:41 +02:00
prelude.rs Use heading for std::prelude and not io::prelude 2021-01-05 17:52:24 -08:00
readbuf.rs use memset to initialize a readbuf 2022-10-08 14:40:19 +02:00
stdio.rs replace version placeholders 2023-04-28 08:47:55 -07:00
tests.rs Limit read size in File::read_to_end loop 2023-04-21 20:54:12 +01:00
util.rs Address reviewer comments 2022-08-18 10:34:40 +01:00