summary refs log tree commit diff
path: root/src/libstd/io
AgeCommit message (Collapse)AuthorLines
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
2019-05-25Add test that impl Seek for BufReader correctly invalidates buffer between seeksChris Gregory-0/+34
2019-05-20Rollup merge of #60511 - taiki-e:libstd-intra-doc, r=Dylan-DPCMazdak Farrokhzad-1/+1
Fix intra-doc link resolution failure on re-exporting libstd Currently, re-exporting libstd items as below will [occur a lot of failures](https://gist.github.com/taiki-e/e33e0e8631ef47f65a74a3b69f456366). ```rust pub use std::*; ``` Until the underlying issue (#56922) fixed, we can fix that so they don't propagate to downstream crates. Related: https://github.com/rust-lang/rust/pull/56941 (That PR fixed failures that occur when re-exporting from libcore to libstd.) r? @QuietMisdreavus
2019-05-18Simplify BufRead doc example using NLLBrent Kerby-9/+4
2019-05-09Rollup merge of #60234 - tesaguri:cursor-default, r=AmanieuMazdak Farrokhzad-1/+1
std: Derive `Default` for `io::Cursor` I think this change is quite obvious, so made it insta-stable, but I won't insist on that.
2019-05-08Inline some Cursor calls for slicesPeter Todd-0/+6
(Partially) brings back https://github.com/rust-lang/rust/pull/33921
2019-05-04Fix intra-doc link resolution failure on re-exporting libstdTaiki Endo-1/+1
2019-04-29Rollup merge of #60334 - sfackler:stable-iovec, r=alexcrichtonMazdak Farrokhzad-89/+103
Stabilized vectored IO This renames `std::io::IoVec` to `std::io::IoSlice` and `std::io::IoVecMut` to `std::io::IoSliceMut`, and stabilizes `std::io::IoSlice`, `std::io::IoSliceMut`, `std::io::Read::read_vectored`, and `std::io::Write::write_vectored`. Closes #58452 r? @alexcrichton
2019-04-27tidySteven Fackler-10/+24
2019-04-27Stabilized vectored IOSteven Fackler-87/+87
This renames `std::io::IoVec` to `std::io::IoSlice` and `std::io::IoVecMut` to `std::io::IoSliceMut`, and stabilizes `std::io::IoSlice`, `std::io::IoSliceMut`, `std::io::Read::read_vectored`, and `std::io::Write::write_vectored`. Closes #58452
2019-04-26Use "capacity" as parameter name in with_capacity() methodsMatthias Geier-7/+7
Closes #60271.
2019-04-24std: Derive `Default` for `io::Cursor`Daiki Mizukami-1/+1
2019-04-14Rollup merge of #59906 - czipperz:bufwriter-use-getmut, r=kennytmMazdak Farrokhzad-2/+2
Make BufWriter use get_mut instead of manipulating inner in Write implementation `get_mut` allows us to abstract over the implementation detail of inner being optional.
2019-04-11Make BufWriter use get_mut instead of manipulating inner in Write implementationChris Gregory-2/+2
get_mut allows us to abstract over the implementation detail of inner being optional.
2019-04-10std: Add `{read,write}_vectored` for more typesAlex Crichton-1/+50
This commit implements the `{read,write}_vectored` methods on more types in the standard library, namely: * `std::fs::File` * `std::process::ChildStd{in,out,err}` * `std::io::Std{in,out,err}` * `std::io::Std{in,out,err}Lock` * `std::io::Std{in,out,err}Raw` Where supported the OS implementations hook up to native support, otherwise it falls back to the already-defaulted implementation.
2019-03-31libstd: deny(elided_lifetimes_in_paths)Mazdak Farrokhzad-34/+34
2019-03-29In doc examples, don't ignore read/write resultsMatt Brubeck-6/+19
Calling `Read::read` or `Write::write` without checking the returned `usize` value is almost always an error. Example code in the documentation should demonstrate how to use the return value correctly. Otherwise, people might copy the example code thinking that it is okay to "fire and forget" these methods.
2019-03-28Use write_all instead of write in example codeMatt Brubeck-7/+7
2019-03-28Rollup merge of #59474 - czipperz:bufwriter-fix-link-capitalization, r=CentrilMazdak Farrokhzad-2/+2
Fix link capitalization in documentation of std::io::BufWriter.
2019-03-27Fix link capitalization in documentation of std::io::BufWriter.Chris Gregory-2/+2
2019-03-27Document that `std::io::BufReader` discards contents on dropChris Gregory-0/+4
Resolves #55546
2019-03-22Add tracking issue number for `seek_convenience`Lukas Kalbertodt-2/+2
2019-03-21Auto merge of #58422 - LukasKalbertodt:seek-convenience, r=alexcrichtonbors-2/+134
Add provided methods `Seek::{stream_len, stream_position}` This adds two new, provided methods to the `io::Seek` trait: - `fn stream_len(&mut self) -> Result<u64>` - `fn stream_position(&mut self) -> Result<u64>` Both are added for convenience and to improve readability in user code. Reading `file.stream_len()` is much better than to manually seek two or three times. Similarly, `file.stream_position()` is much more clear than `file.seek(SeekFrom::Current(0))`. You can find prior discussions [in this internals thread](https://internals.rust-lang.org/t/pre-rfc-idea-extend-io-seek-with-convenience-methods-with-e-g-stream-len/9262). I think I addressed all concerns in that thread. I already wrote three RFCs to add a small new API to libstd but I noticed that many public changes to libstd happen without an RFC. So I figured I can try opening a PR directly without going through RFCs first. After all, we do have rfcbot here too. If you think this change is too big to merge without an RFC, I can still close this PR and write an RFC.
2019-03-21Auto merge of #58913 - Milack27:patch_buf_reader, r=joshtriplettbors-2/+45
Add new test case for possible bug in BufReader When reading a large chunk from a BufReader, if all the bytes from the buffer have been already consumed, the internal buffer is bypassed entirely. However, it is not invalidated, and it's possible to access its contents using the `seek_relative` method, because it tries to reuse the existing buffer.