about summary refs log tree commit diff
path: root/src/libstd/io
AgeCommit message (Collapse)AuthorLines
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-16Remove last use of mem::uninitialized from std::io::utilnathanwhit-4/+9
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.
2019-03-17Apply suggestions from code review Tobias Bucher-2/+2
Fix typos in the documentation Co-Authored-By: LukasKalbertodt <lukas.kalbertodt@gmail.com>
2019-03-16Rollup merge of #59009 - sfackler:fix-sgx-vectors, r=alexcrichtonkennytm-12/+28
Fix SGX implementations of read/write_vectored.
2019-03-14Change "undefined" to "unspecified" in `Seek::stream_len` docsLukas Kalbertodt-1/+1
2019-03-14Overwrite Cursor's `Seek::stream_{len, position}` for performanceLukas Kalbertodt-0/+8
2019-03-14Avoid third seek operation in `Seek::stream_len` when possibleLukas Kalbertodt-5/+12
2019-03-10Add provided methods `Seek::{stream_len, stream_position}`Lukas Kalbertodt-2/+119
These two methods are defined in terms of `Seek::seek` and are added for convenience. Tests are included.
2019-03-09Auto merge of #57882 - euclio:unused-doc-attributes, r=estebankbors-2/+2
overhaul unused doc comments lint This PR contains a number of improvements to the `unused_doc_comments` lint. - Extends the span to cover the entire comment when using sugared doc comments. - Triggers the lint for all unused doc comments on a node, instead of just the first one. - Triggers the lint on macro expansions, and provides a help note explaining that doc comments must be expanded by the macro. - Adds a label pointing at the node that cannot be documented. Furthermore, this PR fixes any instances in rustc where a macro expansion was erroneously documented.
2019-03-08expand unused doc comment diagnosticAndy Russell-2/+2
Report the diagnostic on macro expansions, and add a label indicating why the comment is unused.
2019-03-07Always call read/write from default vectored io methodsSteven Fackler-12/+28
2019-03-06Fix buffer invalidation at BufReader.read_vectoredAndré Vicente Milack-9/+11
2019-03-06Fix buffer invalidation for BufReadAndré Vicente Milack-2/+43
There are two moments when a BufRead object needs to empty it's internal buffer: - In a seek call; - In a read call when all data in the internal buffer had been already consumed and the output buffer has a greater or equal size than the internal buffer. In both cases, the buffer was not being properly emptied, but only marked as consumed (self.pos = self.cap). That should be no problem if the inner reader is only Read, but if it is Seek as well, then it's possible to access the data in the buffer by using the seek_relative method. In order to prevent this from happening, both self.pos and self.cap should be set to 0. Two test cases were added to detect that failure: - test_buffered_reader_invalidated_after_read - test_buffered_reader_invalidated_after_seek Both tests are very similar to each other. The inner reader contains the following data: [5, 6, 7, 0, 1, 2, 3, 4]. The buffer capacity is 3 bytes. - First, we call fill_buffer, which loads [5, 6, 7] into the internal buffer, and then consume those 3 bytes. - Then we either read the 5 remaining bytes in a single read call or we move to the end of the stream by calling seek. In both cases the buffer should be emptied to prevent the previous data [5, 6, 7] from being read. - We now call seek_relative(-2) and read two bytes, which should give us the last 2 bytes of the stream: [3, 4]. Before this commit, the the seek_relative method would consider that we're still in the range of the internal buffer, so instead of fetching data from the inner reader, it would return the two last bytes that were incorrectly still in the buffer: [6, 7]. Therefore, the test would fail. Now, when seek_relative is called the buffer is empty. So the expected data [3, 4] is fetched from the inner reader and the test passes.
2019-03-05libstd: implement Error::source for io::ErrorSean McArthur-0/+8
2019-03-05Auto merge of #58423 - nox:relax-bounds-buf-reader, r=dtolnaybors-0/+2
Relax Read bounds on a bunch of BufReader<R> methods
2019-02-28Use the correct stderr when testing libstdJethro Beekman-2/+28