summary refs log tree commit diff
path: root/library/std/src/io
AgeCommit message (Collapse)AuthorLines
2021-04-22Rework `at_exit` to `cleanup`Christiaan Dirkx-23/+22
2021-04-21Replace all `fmt.pad` with `debug_struct`Christiaan Dirkx-9/+9
2021-04-18Bump to 1.53.0CDirkx-1/+1
Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
2021-04-18Rename `NotSupported` to `Unsupported`Christiaan Dirkx-4/+6
2021-04-18Bump since to 1.52.0CDirkx-1/+1
2021-04-18Add and insta-stabilize `std::io::ErrorKind::NotSupported`Christiaan Dirkx-0/+5
2021-04-13Auto merge of #82992 - philippeitis:stabilize_bufreader_seek_relative, ↵bors-1/+1
r=workingjubilee Stabilize `bufreader_seek_relative` This PR marks `BufReader::seek_relative` as stable - the associated issue, #31100, has passed the final comment period without any issues, and from what I understand, the only thing left to stabilize this is to submit a PR marking the method as stable. Closes #31100.
2021-04-02Auto merge of #80965 - camelid:rename-doc-spotlight, r=jyn514bors-2/+4
Rename `#[doc(spotlight)]` to `#[doc(notable_trait)]` Fixes #80936. "spotlight" is not a very specific or self-explaining name. Additionally, the dialog that it triggers is called "Notable traits". So, "notable trait" is a better name. * Rename `#[doc(spotlight)]` to `#[doc(notable_trait)]` * Rename `#![feature(doc_spotlight)]` to `#![feature(doc_notable_trait)]` * Update documentation * Improve documentation r? `@Manishearth`
2021-03-27Rollup merge of #83555 - m-ou-se:inline-io-error-new-const, r=jackh726Dylan DPC-0/+8
Add #[inline] to io::Error methods Fixes #82812
2021-03-28Rollup merge of #83560 - m-ou-se:io-chain-debug, r=sfacklerYuki Okushi-7/+1
Derive Debug for io::Chain instead of manually implementing it. This derives Debug for io::Chain instead of manually implementing it. The manual implementation has the same bounds, so I don't think there's any reason for a manual implementation. The names used in the derive implementation are even nicer (`first`/`second`) than the manual implementation (`t`/`u`), and include the `done_first` field too.
2021-03-27Derive Debug for io::Chain instead of manually implementing it.Mara Bos-7/+1
The manual implementation has the same bounds, so I don't think there's any reason for a manual implementation. The names used in the derive implementation are even nicer (`first`/`second`) than the manual implementation (`t`/`u`), and include the `done_first` field too.
2021-03-27Use DebugStruct::finish_non_exhaustive() in std.Mara Bos-1/+1
2021-03-27Add #[inline] to io::Error methods.Mara Bos-0/+8
2021-03-24Rollup merge of #83353 - m-ou-se:io-error-avoid-alloc, r=nagisaDylan DPC-15/+63
Add internal io::Error::new_const to avoid allocations. This makes it possible to have a io::Error containing a message with zero allocations, and uses that everywhere to avoid the *three* allocations involved in `io::Error::new(kind, "message")`. The function signature isn't perfect, because it needs a reference to the `&str`. So for now, this is just a `pub(crate)` function. Later, we'll be able to use `fn new_const<MSG: &'static str>(kind: ErrorKind)` to make that a bit better. (Then we'll also be able to use some ZST trickery if that would result in more efficient code.) See https://github.com/rust-lang/rust/issues/83352
2021-03-21Bump stable version of bufreader_seek_relative.Mara Bos-1/+1
2021-03-21Fix typosMara Bos-2/+2
Co-authored-by: the8472 <the8472@users.noreply.github.com>
2021-03-21Use io::Error::new_const everywhere to avoid allocations.Mara Bos-15/+21
2021-03-21Add test for io::Error::new_const.Mara Bos-0/+10
2021-03-21Add internal io::Error::new_const tot avoid allocations.Mara Bos-0/+26
2021-03-21Add test for io::Error's size.Mara Bos-0/+6
2021-03-19Rollup merge of #82892 - jix:clarify-read-read, r=joshtriplettDylan DPC-2/+7
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-18Clarify docs for Read::read's return valueJannis Harder-2/+7
2021-03-15Rename `#[doc(spotlight)]` to `#[doc(notable_trait)]`Camelid-2/+4
"spotlight" is not a very specific or self-explaining name. Additionally, the dialog that it triggers is called "Notable traits". So, "notable trait" is a better name. * Rename `#[doc(spotlight)]` to `#[doc(notable_trait)]` * Rename `#![feature(doc_spotlight)]` to `#![feature(doc_notable_trait)]` * Update documentation * Improve documentation
2021-03-10Stabilize `bufreader_seek_relative`philippeitis-1/+1
2021-03-07Generalize Write impl for Vec<u8> to Vec<u8, A>Joel Höner-1/+2
As discussed in the issue tracker for the wg-allocators working group[1], updating this implementation for allocator support was most likely just forgotten in the original PR. [1]: https://github.com/rust-lang/wg-allocators/issues/86
2021-03-05Rollup merge of #82728 - calebsander:refactor/bufreader-buf, r=m-ou-seMara-4/+3
Avoid unnecessary Vec construction in BufReader As mentioned in #80460, creating a `Vec` and calling `Vec::into_boxed_slice()` emits unnecessary calls to `realloc()` and `free()`. Updated the code to use `Box::new_uninit_slice()` to create a boxed slice directly. I think this also makes it more explicit that the initial contents of the buffer are uninitialized. r? ``@m-ou-se``
2021-03-05Rollup merge of #81136 - Xavientois:io_reader_size_hint, r=cramertjMara-3/+103
Improved IO Bytes Size Hint After trying to implement better `size_hint()` return values for `File` in [this PR](https://github.com/rust-lang/rust/pull/81044) and changing to implementing it for `BufReader` in [this PR](https://github.com/rust-lang/rust/pull/81052), I have arrived at this implementation that provides tighter bounds for the `Bytes` iterator of various readers including `BufReader`, `Empty`, and `Chain`. Unfortunately, for `BufReader`, the size_hint only improves after calling `fill_buffer` due to it using the contents of the buffer for the hint. Nevertheless, the the tighter bounds should result in better pre-allocation of space to handle the contents of the `Bytes` iterator. Closes #81052
2021-03-03Avoid unnecessary Vec construction in BufReaderCaleb Sander-4/+3
2021-03-02Rollup merge of #80189 - jyn514:convert-primitives, r=poliorceticsYuki Okushi-2/+1
Convert primitives in the standard library to intra-doc links Blocked on https://github.com/rust-lang/rust/pull/80181. I forgot that this needs to wait for the beta bump so the standard library can be documented with `doc --stage 0`. Notably I didn't convert `core::slice` because it's like 50 links and I got scared :fearful:
2021-02-27Rollup merge of #82395 - pickfire:see-more, r=GuillaumeGomezDylan DPC-2/+2
Add missing "see its documentation for more" stdio StdoutLock and StderrLock does not have example, it would be better to leave "see its documentation for more" like iter docs.
2021-02-25Convert primitives to use intra-doc linksJoshua Nelson-2/+1
2021-02-24library: Normalize safety-for-unsafe-block commentsMiguel Ojeda-1/+1
Almost all safety comments are of the form `// SAFETY:`, so normalize the rest and fix a few of them that should have been a `/// # Safety` section instead. Furthermore, make `tidy` only allow the uppercase form. While currently `tidy` only checks `core`, it is a good idea to prevent `core` from drifting to non-uppercase comments, so that later we can start checking `alloc` etc. too. Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2021-02-22Add missing "see its documentation for more" stdioIvan Tham-2/+2
StdoutLock and StderrLock does not have example, it would be better to leave "see its documentation for more" like iter docs.
2021-02-20Rollup merge of #82244 - pickfire:patch-6, r=dtolnayGuillaume Gomez-2/+2
Keep consistency in example for Stdin StdinLock Stdin uses handle whereas StdinLock uses stdin_lock, changed it to handle.
2021-02-18Keep consistency in example for Stdin StdinLockIvan Tham-2/+2
Stdin uses handle whereas StdinLock uses stdin_lock, changed it to handle.
2021-02-18Add missing link from stdio docIvan Tham-4/+4
2021-01-31specialize io::copy to use the memory of the writer if it is a BufWriterThe8472-8/+136
2021-01-31Fix line length formatXavientois-1/+3
2021-01-31Fix formatting on modXavientois-2/+1
2021-01-31Add space for proper indentationXavientois-1/+1
2021-01-31Remove trailing newlineXavientois-2/+3
2021-01-31Add tests for SizeHint implementationsXavientois-2/+29
2021-01-31Implement SizeHint trait for BufReader, Emtpy, and ChainXavientois-8/+29
2021-01-31Use fully qualified syntax to avoid dynXavientois-2/+22
2021-01-31Remove unnecessary default keywordXavientois-4/+6
2021-01-31Remove stable annotationXavientois-3/+0
2021-01-31Fix formattingXavientois-10/+2
2021-01-31Add dyn for SizeHint castXavientois-1/+1
2021-01-31Remove exposing private traitXavientois-2/+2
2021-01-31Fix semicolonXavientois-1/+1