about summary refs log tree commit diff
path: root/library/std/src/io
AgeCommit message (Collapse)AuthorLines
2022-05-29Use Box::new() instead of box syntax in std testsest31-3/+3
2022-05-19impl Read and Write for VecDeque<u8>Evan Richter-0/+48
* For read and read_buf, only the front slice of a discontiguous VecDeque is copied. The VecDeque is advanced after reading, making any back slice available for reading with a second call to Read::read(_buf). * For write, the VecDeque always appends the entire slice to the end, growing its allocation when necessary.
2022-05-09Use Rust 2021 prelude in std itself.Mara Bos-3/+0
2022-05-03std::io: Modify some ReadBuf method signatures to return `&mut Self`Nick Cameron-7/+11
This allows using `ReadBuf` in a builder-like style and to setup a `ReadBuf` and pass it to `read_buf` in a single expression, e.g., ``` // With this PR: reader.read_buf(ReadBuf::uninit(buf).assume_init(init_len))?; // Previously: let mut buf = ReadBuf::uninit(buf); buf.assume_init(init_len); reader.read_buf(&mut buf)?; ``` Signed-off-by: Nick Cameron <nrc@ncameron.org>
2022-04-07Rollup merge of #95185 - m-ou-se:stabilize-stdin-lines, r=Mark-SimulacrumDylan DPC-2/+1
Stabilize Stdin::lines. Closes https://github.com/rust-lang/rust/issues/87096 Fcp completed here: https://github.com/rust-lang/rust/issues/87096#issuecomment-1028792980
2022-04-06Bump stabilization of stdin_forwarders to 1.62.0.Mara Bos-1/+1
2022-03-30Auto merge of #95241 - Gankra:cleaned-provenance, r=workingjubileebors-5/+5
Strict Provenance MVP This patch series examines the question: how bad would it be if we adopted an extremely strict pointer provenance model that completely banished all int<->ptr casts. The key insight to making this approach even *vaguely* pallatable is the ptr.with_addr(addr) -> ptr function, which takes a pointer and an address and creates a new pointer with that address and the provenance of the input pointer. In this way the "chain of custody" is completely and dynamically restored, making the model suitable even for dynamic checkers like CHERI and Miri. This is not a formal model, but lots of the docs discussing the model have been updated to try to the *concept* of this design in the hopes that it can be iterated on. See #95228
2022-03-30Rollup merge of #95294 - sourcefrog:doc-copy, r=dtolnayDylan DPC-0/+10
Document Linux kernel handoff in std::io::copy and std::fs::copy
2022-03-29Warn that platform-specific behavior may changeMartin Pool-0/+4
2022-03-29cleanup some of the less terrifying library codeAria Beingessner-1/+1
2022-03-29Make the stdlib largely conform to strict provenance.Aria Beingessner-5/+5
Some things like the unwinders and system APIs are not fully conformant, this only covers a lot of low-hanging fruit.
2022-03-29Indicate the correct error code in the `compile_fail` block.Thom Chiovoloni-1/+1
Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
2022-03-24Document Linux kernel handoff in std::io::copy and std::fs::copyMartin Pool-0/+6
2022-03-23Add a `compile_fail` doctest to check that `io::Error: !UnwindSafe`Thom Chiovoloni-0/+9
2022-03-23Ensure io::Error's bitpacked repr doesn't accidentally impl UnwindSafeThom Chiovoloni-5/+6
2022-03-21Stabilize Stdin::lines.Mara Bos-2/+1
2022-03-19Rollup merge of #93263 - sunfishcode:sunfishcode/detatched-console-handle, ↵Dylan DPC-9/+70
r=dtolnay Consistently present absent stdio handles on Windows as NULL handles. This addresses #90964 by making the std API consistent about presenting absent stdio handles on Windows as NULL handles. Stdio handles may be absent due to `#![windows_subsystem = "windows"]`, due to the console being detached, or due to a child process having been launched from a parent where stdio handles are absent. Specifically, this fixes the case of child processes of parents with absent stdio, which previously ended up with `stdin().as_raw_handle()` returning `INVALID_HANDLE_VALUE`, which was surprising, and which overlapped with an unrelated valid handle value. With this patch, `stdin().as_raw_handle()` now returns null in these situation, which is consistent with what it does in the parent process. And, document this in the "Windows Portability Considerations" sections of the relevant documentation.
2022-03-19Rollup merge of #92663 - cuviper:generic-write-cursor, r=dtolnayDylan DPC-51/+86
Implement `Write for Cursor<[u8; N]>`, plus `A: Allocator` cursor support This implements `Write for Cursor<[u8; N]>`, and also adds support for generic `A: Allocator` in `Box` and `Vec` cursors. This was inspired by a user questioning why they couldn't write a `Cursor<[u8; N]>`: https://users.rust-lang.org/t/why-vec-and-not-u8-makes-cursor-have-write/68210 Related history: - #27197 switched `AsRef<[u8]>` for reading and seeking - #67415 tried to use `AsMut<[u8]>` for writing, but did not specialize `Vec`.
2022-03-18Bump impl Write for Cursor<[u8; N]> to 1.61David Tolnay-1/+1
2022-03-16changed wordingDylan DPC-1/+2
2022-03-15Improve the explanation about the behaviour of read_linezed.zy-1/+1
2022-03-11Update tests.Mara Bos-4/+4
2022-03-11Update advance and advance_slices docs.Mara Bos-14/+28
2022-03-11Panic when advance_slices()'ing too far.Mara Bos-2/+6
2022-03-10Use implicit capture syntax in format_argsT-O-R-U-S-24/+23
This updates the standard library's documentation to use the new syntax. The documentation is worthwhile to update as it should be more idiomatic (particularly for features like this, which are nice for users to get acquainted with). The general codebase is likely more hassle than benefit to update: it'll hurt git blame, and generally updates can be done by folks updating the code if (and when) that makes things more readable with the new format. A few places in the compiler and library code are updated (mostly just due to already having been done when this commit was first authored).
2022-03-04Consistently present absent stdio handles on Windows as NULL handles.Dan Gohman-9/+70
This addresses #90964 by making the std API consistent about presenting absent stdio handles on Windows as NULL handles. Stdio handles may be absent due to `#![windows_subsystem = "windows"]`, due to the console being detached, or due to a child process having been launched from a parent where stdio handles are absent. Specifically, this fixes the case of child processes of parents with absent stdio, which previously ended up with `stdin().as_raw_handle()` returning `INVALID_HANDLE_VALUE`, which was surprising, and which overlapped with an unrelated valid handle value. With this patch, `stdin().as_raw_handle()` now returns null in these situation, which is consistent with what it does in the parent process. And, document this in the "Windows Portability Considerations" sections of the relevant documentation.
2022-03-04Rollup merge of #93965 - Mark-Simulacrum:owned-stdio, r=dtolnayDylan DPC-228/+18
Make regular stdio lock() return 'static handles This also deletes the unstable API surface area previously added to expose this functionality on new methods rather than built into the current set. Closes #86845 (tracking issue for unstable API needed without this) r? ``````@dtolnay`````` to kick off T-libs-api FCP
2022-02-24word wrpaDylan DPC-5/+5
2022-02-24word wrpaDylan DPC-6/+9
2022-02-23Update library/std/src/io/error.rsDylan DPC-1/+1
Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2022-02-23add some more summary from pr discussionDylan DPC-1/+1
2022-02-23add some more summary from pr discussionDylan DPC-2/+4
2022-02-23add matching to errorkindDylan DPC-0/+8
2022-02-13Make default stdio lock() return 'static handlesMark Rousskov-228/+18
This also deletes the unstable API surface area previously added to expose this functionality on new methods rather than built into the current set.
2022-02-10Rename to `InvalidFilename`Yuki Okushi-6/+5
2022-02-10Fix description of FilenameInvalidJosh Triplett-1/+1
Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
2022-02-10Rename `FilenameTooLong` to `FilenameInvalid`Yuki Okushi-2/+2
2022-02-04Add more tests for io::Error packing, and fix some comments that weren't ↵Thom Chiovoloni-16/+101
quite accurate anymore
2022-02-04Update documentation somewhatThom Chiovoloni-12/+26
2022-02-04Use wrapping pointer arithmetic in the bitpacked io::ErrorThom Chiovoloni-8/+15
2022-02-04Elaborate some in the documentation and respond to some review commentsThom Chiovoloni-8/+19
2022-02-04Update library/std/src/io/error/repr_bitpacked.rsThom Chiovoloni-1/+1
Co-authored-by: the8472 <the8472@users.noreply.github.com>
2022-02-04Fix comment typos noticed by code review.Thom Chiovoloni-2/+2
Co-authored-by: Ralf Jung <post@ralfj.de>
2022-02-04Address address comments, improve comments slightlyThom Chiovoloni-5/+20
2022-02-04Optimize io::error::Repr layout on 64 bit targets.Thom Chiovoloni-4/+364
2022-02-04Hide Repr details from io::Error, and rework `io::Error::new_const`.Thom Chiovoloni-91/+178
2022-01-31Rollup merge of #93090 - jyn514:errorkind-asstr, r=dtolnayEric Huss-1/+17
`impl Display for io::ErrorKind` This avoids having to convert from `ErrorKind` to `Error` just to print the error message.
2022-01-20delete `Stdin::split` forwarderTaylor Yu-24/+1
2022-01-19Write for Cursor with a custom AllocatorJosh Stone-7/+23
2022-01-19impl Write for Cursor<[u8; N]>Josh Stone-0/+35