about summary refs log tree commit diff
path: root/src/libstd/io/mod.rs
AgeCommit message (Collapse)AuthorLines
2018-08-01Implement custom read_to_end for io::Takeljedrz-3/+16
2018-07-30Remove unstable and deprecated APIsSimon Sapin-148/+0
2018-07-10Deny bare trait objects in `src/libstd`.ljedrz-2/+2
2018-06-19Remove erroneous example of main as a non-Result function.Sgeo-1/+1
2018-04-15Deprecate Read::chars and char::decode_utf8Simon Sapin-1/+13
Per FCP: * https://github.com/rust-lang/rust/issues/27802#issuecomment-377537778 * https://github.com/rust-lang/rust/issues/33906#issuecomment-377534308
2018-04-05Stabilize take_set_limitThayne McCombs-2/+1
Fixes #42781
2018-04-03Cross-reference fs::read functions from io::Read docsMatt Brubeck-0/+10
2018-03-28Remove hidden `foo` functions from doc examples; use `Termination` trait.Corey Farwell-303/+302
Fixes https://github.com/rust-lang/rust/issues/49233.
2018-02-19Add missing linkAndreas Streichardt-0/+2
2018-02-15Remove "empty buffer" doc in read_untilRoss Light-2/+0
This appears copied from fill_buf, but the above paragraph already indicates that a lack of delimiter at the end is EOF.
2018-01-08Add missing linksGuillaume Gomez-7/+14
2018-01-05Clarify appending behavior of 'io::Read::read_to_string()'.Sergio Benitez-1/+1
2017-12-20Fix some rustdoc warningsGuillaume Gomez-2/+3
2017-12-09Use Try syntax for Option in place of macros or matchMatt Brubeck-4/+3
2017-11-26Rollup merge of #46224 - GuillaumeGomez:io-missing-link, r=QuietMisdreavuskennytm-2/+1
Remove invalid doc link r? @rust-lang/docs
2017-11-23Remove invalid doc linkGuillaume Gomez-2/+1
2017-11-22Rollup merge of #46050 - sunfishcode:read_to_end, r=sfacklerkennytm-6/+3
Optimize `read_to_end`. This patch makes `read_to_end` use Vec's memory-growth pattern rather than using a custom pattern. This has some interesting effects: - If memory is reserved up front, `read_to_end` can be faster, as it starts reading at the buffer size, rather than always starting at 32 bytes. This speeds up file reading by 2x in one of my use cases. - It can reduce the number of syscalls when reading large files. Previously, `read_to_end` would settle into a sequence of 8192-byte reads. With this patch, the read size follows Vec's allocation pattern. For example, on a 16MiB file, it can do 21 read syscalls instead of 2057. In simple benchmarks of large files though, overall speed is still dominated by the actual I/O. - A downside is that Read implementations that don't implement `initializer()` may see increased memory zeroing overhead. I benchmarked this on a variety of data sizes, with and without preallocated buffers. Most benchmarks see no difference, but reading a small/medium file with a pre-allocated buffer is faster.
2017-11-21Auto merge of #45039 - QuietMisdreavus:doc-spotlight, ↵bors-0/+2
r=GuillaumeGomez,QuietMisdreavus show in docs whether the return type of a function impls Iterator/Read/Write Closes #25928 This PR makes it so that when rustdoc documents a function, it checks the return type to see whether it implements a handful of specific traits. If so, it will print the impl and any associated types. Rather than doing this via a whitelist within rustdoc, i chose to do this by a new `#[doc]` attribute parameter, so things like `Future` could tap into this if desired. ### Known shortcomings ~~The printing of impls currently uses the `where` class over the whole thing to shrink the font size relative to the function definition itself. Naturally, when the impl has a where clause of its own, it gets shrunken even further:~~ (This is no longer a problem because the design changed and rendered this concern moot.) The lookup currently just looks at the top-level type, not looking inside things like Result or Option, which renders the spotlights on Read/Write a little less useful: <details><summary>`File::{open, create}` don't have spotlight info (pic of old design)</summary> ![image](https://user-images.githubusercontent.com/5217170/31209495-e59d027e-a950-11e7-9998-ceefceb71c07.png) </details> All three of the initially spotlighted traits are generically implemented on `&mut` references. Rustdoc currently treats a `&mut T` reference-to-a-generic as an impl on the reference primitive itself. `&mut Self` counts as a generic in the eyes of rustdoc. All this combines to create this lovely scene on `Iterator::by_ref`: <details><summary>`Iterator::by_ref` spotlights Iterator, Read, and Write (pic of old design)</summary> ![image](https://user-images.githubusercontent.com/5217170/31209554-50b271ca-a951-11e7-928b-4f83416c8681.png) </details>
2017-11-18Add doc for `Read`ing from `&str` and some related cleanupGarrett Berg-7/+27
2017-11-17spotlight Iterator/Read/Write impls on function return typesQuietMisdreavus-0/+2
2017-11-16Optimize `read_to_end`.Dan Gohman-6/+3
This patch makes `read_to_end` use Vec's memory-growth pattern rather than using a custom pattern. This has some interesting effects: - If memory is reserved up front, `read_to_end` can be faster, as it starts reading at the buffer size, rather than always starting at 32 bytes. This speeds up file reading by 2x in one of my use cases. - It can reduce the number of syscalls when reading large files. Previously, `read_to_end` would settle into a sequence of 8192-byte reads. With this patch, the read size follows Vec's allocation pattern. For example, on a 16MiB file, it can do 21 read syscalls instead of 2057. In simple benchmarks of large files though, overall speed is still dominated by the actual I/O. - A downside is that Read implementations that don't implement `initializer()` may see increased memory zeroing overhead. I benchmarked this on a variety of data sizes, with and without preallocated buffers. Most benchmarks see no difference, but reading a small/medium file with a pre-allocated buffer is faster.
2017-11-14Fixed several pulldown warnings when documenting libstd.kennytm-2/+2
2017-11-01Rollup merge of #45664 - mbrubeck:docs, r=estebankkennytm-4/+5
Fix incorrect error type in Read::byte docs None
2017-10-31Fix incorrect error type in Read::byte docsMatt Brubeck-4/+5
2017-10-31Add a hint what `BufRead` functions do on EOFTobias Bucher-0/+4
2017-09-01Fix testsNick Cameron-1/+1
This is just undoing changes from #41991 because we are not running markdown rendering twice.
2017-08-30Temporary fix for a test (will require another update when this is fully merged)Guillaume Gomez-1/+1
2017-08-24Fix inconsistent doc headingslukaramu-2/+2
This fixes headings reading "Unsafety" and "Example", they should be "Safety" and "Examples" according to RFC 1574.
2017-08-21Add missing links for Read traitGuillaume Gomez-41/+65
2017-08-10Add missing links in io module docsGuillaume Gomez-4/+6
2017-07-11Allow setting the limit on std::io::Take.Mark Simulacrum-0/+29
2017-06-30Stabilize 'more_io_inner_methods' feature.Sergio Benitez-15/+5
2017-06-20Add `Read::initializer`.Steven Fackler-19/+109
This is an API that allows types to indicate that they can be passed buffers of uninitialized memory which can improve performance.
2017-06-16Rollup merge of #42685 - Havvy:doc-remove-sometimes, r=steveklabnikCorey Farwell-1/+1
Remove sometimes in std::io::Read doc We use it immediately in the next sentence, and the word is filler. A different conversation to make is whether we want to call them Readers in the documentation at all. And whether it's actually called "Readers" elsewhere.
2017-06-15Update older URLs pointing to the first edition of the BookWonwoo Choi-1/+1
`compiler-plugins.html` is moved into the Unstable Book. Explanation is slightly modified to match the change.
2017-06-13Remove sometimes in std::io::Read docHavvy-1/+1
We use it immediately in the next sentence, and the word is filler.
2017-05-10Fix up stability annotations per feedback.Zack Weinberg-3/+3
2017-05-10Revise the eprint(ln)! feature.Zack Weinberg-1/+1
* Factor out the nigh-identical bodies of `_print` and `_eprint` to a helper function `print_to` (I was sorely tempted to call it `_doprnt`). * Update the issue number for the unstable `eprint` feature. * Add entries to the "unstable book" for `eprint` and `eprint_internal`. * Style corrections to the documentation.
2017-05-10Add `eprint!` and `eprintln!` macros to the prelude.Zack Weinberg-0/+2
These are exactly the same as `print!` and `println!` except that they write to stderr instead of stdout. Issue #39228.
2017-04-25Rollup merge of #41463 - SergioBenitez:master, r=alexcrichtonCorey Farwell-0/+139
Add internal accessor methods to io::{Chain, Take}. Resolves #29067.
2017-04-24Add cautions to io::get_mut method documentation.Sergio Benitez-0/+8
2017-04-24Reference tracking issue for more_io_inner_methods.Sergio Benitez-5/+5
2017-04-24Add internal accessor methods to io::{Chain, Take}.Sergio Benitez-0/+131
Resolves #29067.
2017-04-21Specify behavior of `write_all` for `ErrorKind::Interrupted` errorsTobias Bucher-6/+16
Also spell out that read and write operations should be retried on `ErrorKind::Interrupted` errors. Fixes #38494.
2017-04-06Fix Markdown issues in the docsOliver Middleton-4/+5
* Since the switch to pulldown-cmark reference links need a blank line before the URLs. * Reference link references are not case sensitive. * Doc comments need to be indented uniformly otherwise rustdoc gets confused.
2017-03-31Rollup merge of #40763 - pirate:patch-2, r=steveklabnikCorey Farwell-0/+12
Add helpful hint in io docs about how ? is not allowed in main() This is my effort to help alleviate the confusion caused by the error message: ```rust error[E0277]: the trait bound `(): std::ops::Carrier` is not satisfied --> hello_world.rs:72:5 | 72 | io::stdin().read_line(&mut d_input)?; | ------------------------------------ | | | the trait `std::ops::Carrier` is not implemented for `()` | in this macro invocation | = note: required by `std::ops::Carrier::from_error` error: aborting due to previous error ``` This has been discussed at length in https://github.com/rust-lang/rust/issues/35946, but I figured it would be helpful to mention in the docs. Reading user input is one of the first things beginners will look up in the docs, so my thinking was they'd see this warning here and not have to deal with the [tricky error message](https://blog.rust-lang.org/2017/03/02/lang-ergonomics.html). If you think this isn't the right place to put this in the docs, that's understandable, I'm open to suggestions for putting it elsewhere or removing it entirely.
2017-03-28add missing importNick Sweeting-0/+2
2017-03-27Fix tidy errors and simplify exampleNick Sweeting-8/+6
2017-03-23Rewrite `io::BufRead` doc examples to better demonstrate behaviors.Corey Farwell-53/+84
Prior to this commit, most of the `BufRead` examples used `StdinLock` to demonstrate how certain `BufRead` methods worked. Using `StdinLock` is not ideal since: * Relying on run-time data means we can't show concrete examples of how these methods work up-front. The user is required to run them in order to see how they behave. * If the user tries to run an example in the playpen, it won't work because the playpen doesn't support user input to stdin.
2017-03-23newline for breathing roomNick Sweeting-0/+1