rust/library/std
Matthias Krüger ce76292014
Rollup merge of #137051 - thaliaarchi:io-optional-impls/empty, r=m-ou-se
Implement default methods for `io::Empty` and `io::Sink`

Implements default methods of `io::Read`, `io::BufRead`, and `io::Write` for `io::Empty` and `io::Sink`. These implementations are equivalent to the defaults, except in doing less unnecessary work.

`Read::read_to_string` and `BufRead::read_line` both have a redundant call to `str::from_utf8` which can't be inlined from `core` and `Write::write_all_vectored` has slicing logic which can't be simplified (See on [Compiler Explorer](https://rust.godbolt.org/z/KK6xcrWr4)). The rest are optimized to the minimal with `-C opt-level=3`, but this PR gives that benefit to unoptimized builds.

This includes an implementation of `Write::write_fmt` which just ignores the `fmt::Arguments<'_>`. This could be problematic whenever a user formatting impl is impure, but the docs do not guarantee that the args will be expanded.

Tracked in https://github.com/rust-lang/rust/issues/136756.

r? `@m-ou-se`
2025-03-19 16:52:53 +01:00
..
benches Fix import in bench for wasm 2025-02-12 14:44:30 -08:00
src Rollup merge of #137051 - thaliaarchi:io-optional-impls/empty, r=m-ou-se 2025-03-19 16:52:53 +01:00
tests Rollup merge of #137793 - NobodyXu:stablise-annoymous-pipe, r=joshtriplett 2025-03-17 05:47:50 -04:00
build.rs Rollup merge of #137621 - Berrysoft:cygwin-std, r=joboet 2025-03-17 05:47:49 -04:00
Cargo.toml Auto merge of #138450 - matthiaskrgr:rollup-4im25vf, r=matthiaskrgr 2025-03-13 13:34:28 +00:00