about summary refs log tree commit diff
path: root/src/libstd/io
AgeCommit message (Collapse)AuthorLines
2020-04-29Rollup merge of #71296 - ChiefMilesEdgeworth:fix_doc_wording, r=Dylan-DPCDylan DPC-2/+3
Change wording on read_vectored docs Closes #70154 I'm happy to work with others to make the wording on this more clear. I think what I have is an improvement but may not be the final wording.
2020-04-26Suppress file length check temporarilySteven Fackler-0/+1
Will clean up in a separate PR
2020-04-26Update nameSteven Fackler-48/+48
2020-04-26Add Read/Write::can_read/write_vectoredSteven Fackler-0/+159
When working with an arbitrary reader or writer, code that uses vectored operations may end up being slower than code that copies into a single buffer when the underlying reader or writer doesn't actually support vectored operations. These new methods allow you to ask the reader or witer up front if vectored operations are efficiently supported. Currently, you have to use some heuristics to guess by e.g. checking if the read or write only accessed the first buffer. Hyper is one concrete example of a library that has to do this dynamically: https://github.com/hyperium/hyper/blob/0eaf304644a396895a4ce1f0146e596640bb666a/src/proto/h1/io.rs#L582-L594
2020-04-25Rollup merge of #71545 - Askaholic:patch-1, r=jonas-schievinkDylan DPC-2/+2
Fix comment in docstring example for Error::kind Saw it while reading the docs.
2020-04-25Fix comment in docstring example for Error::kindAskaholic-2/+2
2020-04-24Replace filter_map().next() calls with find_map()Josh Stone-9/+4
These are semantically the same, but `find_map()` is more concise.
2020-04-18Change wording on read_vectored docsNathan Abel-2/+3
2020-04-07Rollup merge of #70612 - Thomasdezeeuw:issue_70436, r=LukasKalbertodtDylan DPC-1/+169
Add io::Write::write_all_vectored Similar to io::Write::write_all but uses io::Write::write_vectored instead. Updates #70436 /cc @cramertj @sfackler
2020-04-07Put reference to write_vectored in quotes in docThomas de Zeeuw-1/+1
2020-04-06Improve io::Write::write_all_vectored docsThomas de Zeeuw-11/+17
Also adds some more tests with different length IoSlices.
2020-04-01Fix link to write_vectoredThomas de Zeeuw-1/+1
2020-04-01Use unspecified over undefined in io::Write::write_all_vectored docsThomas de Zeeuw-7/+9
2020-03-31Add io::Write::write_all_vectoredThomas de Zeeuw-1/+161
Similar to io::Write::write_all but uses io::Write::write_vectored instead.
2020-03-31more clippy fixesMatthias Krüger-2/+2
use is_empty() instead of len comparison (clippy::len_zero) use if let instead of while let loop that never loops (clippy::never_loop) remove redundant returns (clippy::needless_return) remove redundant closures (clippy::redundant_closure) use if let instead of match and wildcard pattern (clippy::single_match) don't repeat field names redundantly (clippy::redundant_field_names)
2020-03-24spaces between braces really ruin readabilityWithout Boats-4/+4
2020-03-24correct rustc versionWithout Boats-2/+2
2020-03-24IoSlice/IoSliceMut should be Send and SyncWithout Boats-0/+12
2020-03-21Rollup merge of #70232 - adrian5:patch-1, r=Dylan-DPCDylan DPC-1/+1
Tweak wording for std::io::Read::read function I think the sentence as a whole reads smoother that way.
2020-03-21Tweak wording for std::io::Read::read functionadrian5-1/+1
2020-03-21Rollup merge of #69955 - alexcrichton:stderr-infallible, r=sfacklerDylan DPC-18/+31
Fix abort-on-eprintln during process shutdown This commit fixes an issue where if `eprintln!` is used in a TLS destructor it can accidentally cause the process to abort. TLS destructors are executed after `main` returns on the main thread, and at this point we've also deinitialized global `Lazy` values like those which store the `Stderr` and `Stdout` internals. This means that despite handling TLS not being accessible in `eprintln!`, we will fail due to not being able to call `stderr()`. This means that we'll double-panic quickly because panicking also attempt to write to stderr. The fix here is to reimplement the global stderr handle to avoid the need for destruction. This avoids the need for `Lazy` as well as the hidden panic inside of the `stderr` function. Overall this should improve the robustness of printing errors and/or panics in weird situations, since the `stderr` accessor should be infallible in more situations.
2020-03-20Fix abort-on-eprintln during process shutdownAlex Crichton-18/+31
This commit fixes an issue where if `eprintln!` is used in a TLS destructor it can accidentally cause the process to abort. TLS destructors are executed after `main` returns on the main thread, and at this point we've also deinitialized global `Lazy` values like those which store the `Stderr` and `Stdout` internals. This means that despite handling TLS not being accessible in `eprintln!`, we will fail due to not being able to call `stderr()`. This means that we'll double-panic quickly because panicking also attempt to write to stderr. The fix here is to reimplement the global stderr handle to avoid the need for destruction. This avoids the need for `Lazy` as well as the hidden panic inside of the `stderr` function. Overall this should improve the robustness of printing errors and/or panics in weird situations, since the `stderr` accessor should be infallible in more situations.
2020-03-19Rollup merge of #69959 - alexcrichton:fix-panic-in-print, r=Mark-SimulacrumMazdak Farrokhzad-4/+8
std: Don't abort process when printing panics in tests This commit fixes an issue when using `set_print` and friends, notably used by libtest, to avoid aborting the process if printing panics. This previously panicked due to borrowing a mutable `RefCell` twice, and this is worked around by borrowing these cells for less time, instead taking out and removing contents temporarily. Closes #69558
2020-03-18std: Don't abort process when printing panics in testsAlex Crichton-4/+8
This commit fixes an issue when using `set_print` and friends, notably used by libtest, to avoid aborting the process if printing panics. This previously panicked due to borrowing a mutable `RefCell` twice, and this is worked around by borrowing these cells for less time, instead taking out and removing contents temporarily. Closes #69558
2020-03-14Rollup merge of #69403 - LeSeulArtichaut:copy-ioslice, r=sfacklerYuki Okushi-0/+1
Implement `Copy` for `IoSlice` Resolves #69395 r? @sfackler
2020-03-10Rollup merge of #69514 - GuillaumeGomez:remove-spotlight, r=kinnisonMazdak Farrokhzad-2/+0
Remove spotlight I had a few comments saying that this feature was at best misunderstood or not even used so I decided to organize a poll about on [twitter](https://twitter.com/imperioworld_/status/1232769353503956994). After 87 votes, the result is very clear: it's not useful. Considering the amount of code we have just to run it, I think it's definitely worth it to remove it. r? @kinnison cc @ollie27
2020-03-06Don't redundantly repeat field names (clippy::redundant_field_names)Matthias Krüger-3/+3
2020-02-27use char instead of &str for single char patternsMatthias Krüger-2/+2
2020-02-27Remove spotlight usageGuillaume Gomez-2/+0
2020-02-23docs: Stdin::read_line: mention the appendingJakub Kądziołka-1/+1
2020-02-23Implement `Copy` for `IoSlice`LeSeulArtichaut-0/+1
2020-02-05Fix issue number of `capacity` methodYuki Okushi-2/+2
2020-02-04Auto merge of #68558 - HeroicKatora:buf-writer-capacity, r=alexcrichtonbors-0/+45
Add a method to query the capacity of a BufWriter and BufReader Besides the obvious of retrieving the parameter used to construct the writer, this method allows consumers to control the number of `flush` calls during write operations. For `BufReader` it gives an upper bound on the returned buffer in `fill_buf` which might influence the allocation behaviour of a consumer.
2020-01-28Document that write_all will not call write if given an empty bufferJosh Triplett-0/+2
Some types of Write instances have a semantic meaning associated with writing an empty buffer, such as sending an empty packet. This works when calling `write` directly, and supplying an empty buffer. However, calling `write_all` on an empty buffer will simply never call `write`, because `write_all` assumes it has no work to do. Document this behavior, to help prospective users of datagram-packet-style Write instances.
2020-01-28Add capacity to BufReader with same unstable gateAndreas Molzer-0/+26
2020-01-26Add a method to query the capacity of a BufWriterAndreas Molzer-0/+19
2020-01-02Use drop instead of the toilet closure `|_| ()`Lzu Tao-1/+1
2019-12-24Deprecate Error::description for realDavid Tolnay-8/+6
`description` has been documented as soft-deprecated since 1.27.0 (17 months ago). There is no longer any reason to call it or implement it. This commit: - adds #[rustc_deprecated(since = "1.41.0")] to Error::description; - moves description (and cause, which is also deprecated) below the source and backtrace methods in the Error trait; - reduces documentation of description and cause to take up much less vertical real estate in rustdocs, while preserving the example that shows how to render errors without needing to call description; - removes the description function of all *currently unstable* Error impls in the standard library; - marks #[allow(deprecated)] the description function of all *stable* Error impls in the standard library; - replaces miscellaneous uses of description in example code and the compiler.
2019-12-24Rollup merge of #67561 - euclio:remove-description, r=jonas-schievinkMazdak Farrokhzad-3/+1
remove `description` from `Error` impls in docs Since `description` is soft-deprecated, there's no need to show it implemented in these examples.
2019-12-23remove `description` from `Error` impls in docsAndy Russell-3/+1
2019-12-23Rollup merge of #67233 - Luro02:cursor_traits, r=sfacklerMazdak Farrokhzad-1/+13
Add PartialEq and Eq to Cursor closes #67226
2019-12-22Format the worldMark Rousskov-132/+189
2019-12-22add partialeq and eq to cursorLuro02-1/+13
2019-12-21Require issue = "none" over issue = "0" in unstable attributesRoss MacArthur-5/+5
2019-12-12std: Implement `LineWriter::write_vectored`Alex Crichton-1/+171
This commit implements the `write_vectored` method of the `LineWriter` type. First discovered in bytecodealliance/wasmtime#629 the `write_vectored` method of `Stdout` bottoms out here but only ends up writing the first buffer due to the default implementation of `write_vectored`. Like `BufWriter`, however, `LineWriter` can have a non-default implementation of `write_vectored` which tries to preserve the vectored-ness as much as possible. Namely we can have a vectored write for everything before the newline and everything after the newline if all the stars align well. Also like `BufWriter`, though, special care is taken to ensure that whenever bytes are written we're sure to signal success since that represents a "commit" of writing bytes.
2019-12-05Simplify {IoSlice, IoSliceMut}::advance examples and testsTomasz Miąsko-29/+26
Remove unnecessary calls to `std::mem::replace` and make variables immutable.
2019-11-29Format libstd with rustfmtDavid Tolnay-215/+283
This commit applies rustfmt with rust-lang/rust's default settings to files in src/libstd *that are not involved in any currently open PR* to minimize merge conflicts. THe list of files involved in open PRs was determined by querying GitHub's GraphQL API with this script: https://gist.github.com/dtolnay/aa9c34993dc051a4f344d1b10e4487e8 With the list of files from the script in outstanding_files, the relevant commands were: $ find src/libstd -name '*.rs' \ | xargs rustfmt --edition=2018 --unstable-features --skip-children $ rg libstd outstanding_files | xargs git checkout -- Repeating this process several months apart should get us coverage of most of the rest of libstd. To confirm no funny business: $ git checkout $THIS_COMMIT^ $ git show --pretty= --name-only $THIS_COMMIT \ | xargs rustfmt --edition=2018 --unstable-features --skip-children $ git diff $THIS_COMMIT # there should be no difference
2019-11-08docs: Fix link to BufWriter::flushBryan Burgers-1/+1
One of the links in the docs was being rendered as a literal open-bracket followed by a single quote, instead of being transformed into a link. Fix it to match the link earlier in the same paragraph.
2019-10-31rephrase sentence regarding data loss when using BufReader::into_innerMarco Conte-2/+3
2019-10-31enhance the documentation of std::io::BufReader regarding potential data lossMarco Conte-2/+4