about summary refs log tree commit diff
path: root/tests/codegen/src-hash-algorithm/src-hash-algorithm-sha256.rs
diff options
context:
space:
mode:
authorMichal Nazarewicz <mina86@mina86.com>2023-01-22 15:46:53 +0100
committerMichal Nazarewicz <mina86@mina86.com>2023-01-24 03:04:05 +0100
commit316742edb73a81edc231b1c8dc086fae1f3142d9 (patch)
treeb11bb3578cabc1e96386751326aeec441a068535 /tests/codegen/src-hash-algorithm/src-hash-algorithm-sha256.rs
parentc8e6a9e8b6251bbc8276cb78cabe1998deecbed7 (diff)
downloadrust-316742edb73a81edc231b1c8dc086fae1f3142d9.tar.gz
rust-316742edb73a81edc231b1c8dc086fae1f3142d9.zip
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
Diffstat (limited to 'tests/codegen/src-hash-algorithm/src-hash-algorithm-sha256.rs')
0 files changed, 0 insertions, 0 deletions