about summary refs log tree commit diff
path: root/library/std/src/io
AgeCommit message (Collapse)AuthorLines
2024-11-14Rollup merge of #132790 - aDotInTheVoid:ioslice-asslice-rides-again, r=cuviperJubilee-0/+59
Add as_slice/into_slice for IoSlice/IoSliceMut. ACP: https://github.com/rust-lang/libs-team/issues/93 Tracking issue: #132818 Based on a623c5233ae7f6b540e5c00f2be02f40b33b0793 (CC `@mpdn)` and #111277 (CC `@Lucretiel).` Closes: #124659 Tracking Issue: TODO try-job: test-various try-job: dist-various-1 try-job: dist-various-2 r? libs
2024-11-09Add as_slice/into_slice for IoSlice/IoSliceMut.Alona Enraght-Moony-0/+59
Co-authored-by: Mike Pedersen <mike@mikepedersen.dk> Co-authored-by: Nathan West <Lucretiel@gmail.com>
2024-11-08update io::Error::into_inner to acknowlage io::Error::otherbinarycat-2/+4
2024-10-23Specialize `read_exact` and `read_buf_exact` for `VecDeque`Benoît du Garreau-0/+46
2024-10-15replace placeholder versionJosh Stone-17/+17
(cherry picked from commit 567fd9610cbfd220844443487059335d7e1ff021)
2024-10-10More clearly document Stdin::read_lineTim (Theemathas) Chirananthavat-1/+6
These are common pitfalls for beginners, so I think it's worth making the subtleties more visible.
2024-10-05Unbreak tidyPavel Grigorenko-5/+5
2024-10-05Stabilize `std::io::ErrorKind::QuotaExceeded`Pavel Grigorenko-5/+5
Also drop "Filesystem" from its name
2024-10-04Stabilize `BufRead::skip_until`okaneco-3/+1
2024-10-02Add `get_line` confusable to `Stdin::read_line()`Jaken Herman-0/+1
Add tests for addition of `#[rustc_confusables("get_line")]`
2024-09-30Rollup merge of #130914 - compiler-errors:insignificant-dtor, r=AmanieuTrevor Gross-0/+1
Mark some more types as having insignificant dtor These were caught by https://github.com/rust-lang/rust/pull/129864#issuecomment-2376658407, which is implementing a lint for some changes in drop order for temporaries in tail expressions. Specifically, the destructors of `CString` and the bitpacked repr for `std::io::Error` are insignificant insofar as they don't have side-effects on things like locking or synchronization; they just free memory. See some discussion on #89144 for what makes a drop impl "significant"
2024-09-29Fix std tests for wasm32-wasip2 targetNicola Krumschmidt-5/+6
2024-09-28Rollup merge of #125404 - a1phyr:fix-read_buf-uses, r=workingjubileeMatthias Krüger-16/+88
Fix `read_buf` uses in `std` Following lib-team decision here: https://github.com/rust-lang/rust/issues/78485#issuecomment-2122992314 Guard against the pathological behavior of both returning an error and performing a read.
2024-09-27Mark some more types as having insignificant dtorMichael Goulet-0/+1
2024-09-25Add tracking issue for io_error_inprogressnora-1/+1
2024-09-25Auto merge of #130803 - cuviper:file-buffered, r=joshtriplettbors-1/+29
Add `File` constructors that return files wrapped with a buffer In addition to the light convenience, these are intended to raise visibility that buffering is something you should consider when opening a file, since unbuffered I/O is a common performance footgun to Rust newcomers. ACP: https://github.com/rust-lang/libs-team/issues/446 Tracking Issue: #130804
2024-09-24Mark 'get_mut' and 'set_position' in 'std::io::Cursor' as const;Gabriel Bjørnager Jensen-2/+4
2024-09-24Pre-allocate buffers in `File::open_buffered` and `create_buffered`Josh Stone-1/+29
2024-09-24add InProgress ErrorKind gated behind io_error_inprogress featureAviram Hassan-0/+7
Co-authored-by: David Tolnay <dtolnay@gmail.com> Co-authored-by: nora <48135649+Noratrieb@users.noreply.github.com>
2024-09-23Add a comment to `Read::read_buf`Benoît du Garreau-0/+2
2024-09-23Add testsBenoît du Garreau-0/+63
2024-09-23Fix `io::default_read_to_end` uses of `read_buf`Benoît du Garreau-10/+14
2024-09-23Fix `io::BufReader` uses of `read_buf`Benoît du Garreau-2/+4
2024-09-23Fix `io::Take::read_buf`Benoît du Garreau-4/+5
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-16/+15
2024-09-21wait for two short reads before uncapping the max read sizeThe 8472-3/+13
for disk IO: 1st short read = probably at end of file 2nd short read = confirming that it's indeed EOF
2024-09-20[Clippy] Remove final std paths for diagnostic itemGnomedDev-0/+1
2024-09-15Rollup merge of #130042 - lolbinarycat:bufreaker_peek_eof, r=AmanieuStuart Cook-4/+12
properly handle EOF in BufReader::peek previously this would cause an infinite loop due to it being unable to read `n` bytes.
2024-09-11Stabilize `std::io::ErrorKind::CrossesDevices`Pavel Grigorenko-1/+1
2024-09-10Auto merge of #130025 - Urgau:missing_docs-expect, r=petrochenkovbors-0/+1
Also emit `missing_docs` lint with `--test` to fulfil expectations This PR removes the "test harness" suppression of the `missing_docs` lint to be able to fulfil `#[expect]` (expectations) as it is now "relevant". I think the goal was to maybe avoid false-positive while linting on public items under `#[cfg(test)]` but with effective visibility we should no longer have any false-positive. Another possibility would be to query the lint level and only emit the lint if it's of expect level, but that is even more hacky. Fixes https://github.com/rust-lang/rust/issues/130021 try-job: x86_64-gnu-aux
2024-09-09Rollup merge of #128316 - GrigorenkoPV:io_error_a_bit_more, r=dtolnayJubilee-16/+16
Stabilize most of `io_error_more` Sadly, venting my frustration with t-libs-api is not a constructive way to solve problems and get things done, so I will try to stick to stuff that actually matters here. - Tracking issue for this feature was opened 3 years ago: #86442 - FCP to stabilize it was completed 19(!!) months ago: https://github.com/rust-lang/rust/issues/86442#issuecomment-1368082102 - A PR with stabilization was similarly open for 19 months: #106375, but nothing ever came out of it. Presumably (it is hard to judge given the lack of communication) because a few of the variants still had some concerns voiced about them, even after the FCP. So, to highlight a common sentiment: > Maybe uncontroversial variants can be stabilised first and other variants (such as `QuotaExceeded` or `FilesystemLoop`) later? [^1] [^1]: https://github.com/rust-lang/rust/issues/106375#issuecomment-1435762236 > I would like to voice support stabilization of the uncontroversial variants. This would get those variants to stable and focus the discussion around the more controversial ones. I don't see any particular reason that all of these must be stabilized at the same time. [...] [^2] [^2]: https://github.com/rust-lang/rust/pull/106375#issuecomment-1742661555 > Maybe some less-controversial subset could be stabilized sooner? What’s blocking this issue from making progress? [^3] [^3]: https://github.com/rust-lang/rust/issues/86442#issuecomment-1691187483 (got 30 upvotes btw) (and no response) So this is exactly what this PR does. It stabilizes the non-controversial variants now, leaving just a few of them behind. Namely, this PR stabilizes: - `HostUnreachable` - `NetworkUnreachable` - `NetworkDown` - `NotADirectory` - `IsADirectory` - `DirectoryNotEmpty` - `ReadOnlyFilesystem` - `StaleNetworkFileHandle` - `StorageFull` - `NotSeekable` - `FileTooLarge` - `ResourceBusy` - `ExecutableFileBusy` - `Deadlock` - `TooManyLinks` - `ArgumentListTooLong` - `Unsupported` This PR does not stabilize: - `FilesystemLoop` - `FilesystemQuotaExceeded` - `CrossesDevices` - `InvalidFilename` Hopefully, this will allow us to move forward with this highly and long awaited addition to std, both allowing to still polish the less clear parts of it and not leading to stagnation. r? joshtriplett because they seem to be listed as a part of t-libs-api and were one of the most responsive persons previously
2024-09-09Add missing `#[allow(missing_docs)]` on hack functions in allocUrgau-0/+1
2024-09-06properly handle EOF in BufReader::peekbinarycat-4/+12
previously this would cause an infinite loop due to it being unable to read `n` bytes.
2024-09-02Rollup merge of #129804 - ranger-ross:fixed-documentation-typos, r=NoratriebMatthias Krüger-1/+1
Fixed some typos in the standard library documentation/comments I spent some time to fix a few typos in `library/std` and `library/core`
2024-08-31Fixed some typos in the standard library documentation/commentsranger-ross-1/+1
2024-08-28allow BufReader::peek to be called on unsized typesbinarycat-0/+2
2024-08-07Rollup merge of #128406 - lolbinarycat:bufreader_peek, r=Mark-SimulacrumMatthias Krüger-0/+55
implement BufReader::peek Part of https://github.com/rust-lang/rust/issues/128405
2024-08-05implement BufReader::peekbinarycat-0/+55
2024-07-30Auto merge of #128083 - Mark-Simulacrum:bump-bootstrap, r=albertlarsan68bors-4/+4
Bump bootstrap compiler to new beta https://forge.rust-lang.org/release/process.html#master-bootstrap-update-t-2-day-tuesday
2024-07-29Rollup merge of #109174 - soerenmeier:cursor_fns, r=dtolnayMatthias Krüger-32/+37
Replace `io::Cursor::{remaining_slice, is_empty}` This is a late follow up to the concerns raised in https://github.com/rust-lang/rust/issues/86369. https://github.com/rust-lang/rust/issues/86369#issuecomment-953096691 > This API seems focussed on the `Read` side of things. When `Seek`ing around and `Write`ing data, `is_empty` becomes confusing and `remaining_slice` is not very useful. When writing, the part of the slice before the cursor is much more interesting. Maybe we should have functions for both? Or a single function that returns both slices? (If we also have a `mut` version, a single function would be useful to allow mutable access to both sides at once.) New feature name: `cursor_remaining` > `cursor_split`. Added functions: ```rust fn split(&self) -> (&[u8], &[u8]); // fn before(&self) -> &[u8]; // fn after(&self) -> &[u8]; fn split_mut(&mut self) -> (&mut [u8], &mut [u8]); // fn before_mut(&mut self) -> &mut [u8]; // fn after_mut(&mut self) -> &mut [u8]; ``` A question was raised in https://github.com/rust-lang/rust/issues/86369#issuecomment-927124211 about whether to return a lifetime that would reflect the lifetime of the underlying bytes (`impl Cursor<&'a [u8]> { fn after(&self) -> &'a [u8] }`). The downside of doing this would be that it would not be possible to implement these functions generically over `T: AsRef<[u8]>`. ## Update Based on the review, before* and after* methods where removed.
2024-07-29Reformat `use` declarations.Nicholas Nethercote-49/+35
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-28Replace `io::Cursor::{remaining_slice, is_empty}` with `io::Cursor::{split, ↵Sören Meier-32/+37
split_mut}`
2024-07-28Partially stabilize `io_error_more`Pavel Grigorenko-16/+16
2024-07-28Update CURRENT_RUSTC_VERSIONMark Rousskov-4/+4
2024-07-26Fix doc nitsJohn Arundel-36/+40
Many tiny changes to stdlib doc comments to make them consistent (for example "Returns foo", rather than "Return foo", per RFC1574), adding missing periods, paragraph breaks, backticks for monospace style, and other minor nits. https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md#appendix-a-full-conventions-text
2024-07-19Avoid ref when using format! for perfYuri Astrakhan-1/+1
Clean up a few minor refs in `format!` macro, as it has a tiny perf cost. A few more minor related cleanups.
2024-07-14std: Unsafe-wrap std::ioJubilee Young-9/+13
2024-07-14std: deny(unsafe_op_in_unsafe_fn) but allow sitesJubilee Young-0/+1
This provides a list of locations to hunt down issues in.
2024-07-13Rollup merge of #127659 - saethlin:manually-drop-bufwriter, r=joboetJubilee-7/+17
Use ManuallyDrop in BufWriter::into_parts The fact that `mem::forget` takes by value means that it interacts very poorly with Stacked Borrows; generally users think of calling it as a no-op, but in Stacked Borrows, the field retagging tends to cause surprise tag invalidation.
2024-07-12Use ManuallyDrop in BufWriter::into_partsBen Kimock-7/+17