about summary refs log tree commit diff
path: root/src/libstd/io
AgeCommit message (Collapse)AuthorLines
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
2019-10-20Fix parameter name in documentationAdrian Heine né Lang-1/+1
2019-09-16Fix inconsistent link formattingIvan Tham-6/+6
2019-09-11Fix inconsistent link formatting.Tomasz Różański-4/+4
2019-09-03Changed comment to better reflect std's exceptional situationDaniel Henry-Mantilla-4/+4
2019-09-03Added warning around code with reference to uninit bytesDaniel Henry-Mantilla-0/+8
2019-08-31clarify that not all errors are observedJohn Erickson-2/+3
2019-08-31Add in generic type to description of BufReader and BufWriterJohn Erickson-17/+17
2019-08-31Update BufWriter example to include call to flush()John Erickson-6/+7
2019-08-06avoid unnecessary reservations in std::io::Take::read_to_endJack O'Connor-8/+58
Prevously the `read_to_end` implementation for `std::io::Take` used its own `limit` as a cap on the `reservation_size`. However, that could still result in an over-allocation like this: 1. Call `reader.take(5).read_to_end(&mut vec)`. 2. `read_to_end_with_reservation` reserves 5 bytes and calls `read`. 3. `read` writes 5 bytes. 4. `read_to_end_with_reservation` reserves 5 bytes and calls `read`. 5. `read` writes 0 bytes. 6. The read loop ends with `vec` having length 5 and capacity 10. The reservation of 5 bytes was correct for the read at step 2 but unnecessary for the read at step 4. By that second read, `Take::limit` is 0, but the `read_to_end_with_reservation` loop is still using the same `reservation_size` it started with. Solve this by having `read_to_end_with_reservation` take a closure, which lets it get a fresh `reservation_size` for each read. This is an implementation detail which doesn't affect any public API.
2019-08-03Add {IoSlice, IoSliceMut}::advanceThomas de Zeeuw-1/+199
2019-08-01Rollup merge of #62644 - arnottcr:std_io-doc, r=steveklabnikPietro Albini-1/+1
simplify std::io::Write::write rustdoc The std::io::Write::write method currensly suggests consumers guaranteed that `0 <= n <= buf.len()`, for `Ok(n)`, however `n` is of type `usize` causing the compiler to emit a warning: ``` warning: comparison is useless due to type limits --> lib.rs:6:18 | 6 | Ok(n) => 0 <= n && n <= output.len(), | ^^^^^^ | = note: #[warn(unused_comparisons)] on by default ``` This PR removes the suggestion to check `0 <= n` since it is moot. r? @steveklabnik
2019-07-28Rollup merge of #62806 - mati865:clippy, r=TimNNMazdak Farrokhzad-2/+2
Fix few Clippy warnings
2019-07-22Rollup merge of #62845 - RalfJung:read, r=rkruppeMazdak Farrokhzad-2/+2
read: fix doc comment No idea how that happened...
2019-07-21read: fix doc commentRalf Jung-2/+2
2019-07-19ONCE_INIT is deprecated-in-future only for bootstrapRalf Jung-1/+1
2019-07-19do not use mem::uninitialized in std::ioRalf Jung-14/+10
2019-07-18Fix clippy::len_zero warningsMateusz Mikuła-2/+2
2019-07-16Remove last use of mem::uninitialized from std::io::utilnathanwhit-4/+9
2019-07-13simplify std::io::Write::write rustdocColin Arnott-1/+1
The std::io::Write::write method currensly suggests consumers guaranteed that `0 <= n <= buf.len()`, for `Ok(n)`, however `n` is of type `usize` causing the compiler to emit a warning: ``` warning: comparison is useless due to type limits --> lib.rs:6:18 | 6 | Ok(n) => 0 <= n && n <= output.len(), | ^^^^^^ | = note: #[warn(unused_comparisons)] on by default ``` This PR removes the suggestion to check `0 <= n` since it is moot. r? @steveklabnik
2019-07-05Rollup merge of #62381 - pawroman:fix_typo_in_write_vectored, r=CentrilMazdak Farrokhzad-1/+1
Fix a typo in Write::write_vectored docs Fixed what seems like a typo. "Copy to from" is extremely confusing.
2019-07-04Permit use of mem::uninitialized via allow(deprecated)Mark Rousskov-0/+1
2019-07-04Fix a typo in Write::write_vectored docsPaweł Romanowski-1/+1
2019-06-25tweak wordingRalf Jung-3/+3
2019-06-24call out explicitly that general read needs to be called with an initialized ↵Ralf Jung-1/+10
buffer
2019-05-29Rollup merge of #61235 - lzutao:stabilize-bufreader_buffer, r=CentrilMazdak Farrokhzad-4/+2
Stabilize bufreader_buffer feature FCP done in https://github.com/rust-lang/rust/issues/45323#issuecomment-495937047 Closes #45323 r? @SimonSapin
2019-05-27Stabilize bufreader_buffer featureLzu Tao-4/+2
2019-05-25Annotate test with #[test]Chris Gregory-0/+1