about summary refs log tree commit diff
path: root/src/libstd/io
AgeCommit message (Collapse)AuthorLines
2017-04-06Fix Markdown issues in the docsOliver Middleton-12/+14
* 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-28Rollup merge of #40783 - stepancheg:cursor-new-0, r=aturonCorey Farwell-0/+4
Document Cursor::new position is 0 ... even if contained `Vec` is not empty. E. g. for ``` let v = vec![10u8, 20]; let mut c = io::Cursor::new(v); c.write_all(b"aaaa").unwrap(); println!("{:?}", c.into_inner()); ``` result is ``` [97, 97, 97, 97] ``` and not ``` [10, 20, 97, 97, 97, 97] ```
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-24Document Cursor::new position is 0Stepan Koltsov-0/+4
... even if contained `Vec` is not empty. E. g. for ``` let v = vec![10u8, 20]; let mut c = io::Cursor::new(v); c.write_all(b"aaaa").unwrap(); println!("{:?}", c.into_inner()); ``` result is ``` [97, 97, 97, 97] ``` and not ``` [10, 20, 97, 97, 97, 97] ```
2017-03-23newline for breathing roomNick Sweeting-0/+1
2017-03-23requested changesNick Sweeting-1/+2
2017-03-23Add helpful hint on io function for beginnersNick Sweeting-0/+10
2017-03-13Remove function invokation parens from documentation links.Corey Farwell-53/+53
This was never established as a convention we should follow in the 'More API Documentation Conventions' RFC: https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md
2017-03-01Only keep one copy of the UTF8_CHAR_WIDTH table.Simon Sapin-1/+1
… instead of one of each of libcore and libstd_unicode. Move the `utf8_char_width` function to `core::str` under the `str_internals` unstable feature.
2017-02-16std::io::cursor: Fixed Seek so test passes.Amos Onn-10/+12
2017-02-16std::io::cursor Added test for seeking beyond i64.Amos Onn-0/+37
2017-01-29Fix a few impl stability attributesOliver Middleton-10/+10
The versions show up in rustdoc.
2017-01-22libstd: mention `?` operator instead of removing `try!` macro referenceUtkarsh Kukreti-1/+3
2017-01-22libstd: update std::io module documentation to not mention `try!`Utkarsh Kukreti-3/+1
We're not using it in the examples anymore.
2017-01-22libstd: replace all `try!` with `?` in documentation examplesUtkarsh Kukreti-89/+89
See #38644.
2017-01-13Change `to_owned` to `to_string` in docsStjepan Glavina-2/+2
We should teach conversion from `str` to `String` using `to_string` rather than the legacy `to_owned`.
2016-12-24Rollup merge of #38505 - estebank:why-lines, r=frewsxcvSteve Klabnik-0/+6
Docs: Explain why/when `.lines()` returns an error Fix #37744.
2016-12-24Auto merge of #38062 - alexcrichton:fix-line-writer, r=brsonbors-13/+86
std: Fix partial writes in LineWriter Previously the `LineWriter` could successfully write some bytes but then fail to report that it has done so. Additionally, an erroneous flush after a successful write was permanently ignored. This commit fixes these two issues by (a) maintaining a `need_flush` flag to indicate whether a flush should be the first operation in `LineWriter::write` and (b) avoiding returning an error once some bytes have been successfully written. Closes #37807
2016-12-20Docs: Explain why/when `.lines()` returns an errorEsteban Küber-0/+6
2016-12-18Implement `fmt::Debug` for all structures in libstd.Corey Farwell-0/+79
Part of https://github.com/rust-lang/rust/issues/31869. Also turn on the `missing_debug_implementations` lint at the crate level.
2016-12-16Address falloutAaron Turon-3/+3
2016-12-15Stabilize std::io::Take::into_innerAaron Turon-3/+1
2016-12-12Merge branch 'master' into redoxJeremy Soller-3/+21
2016-12-12Auto merge of #38049 - frewsxcv:libunicode, r=alexcrichtonbors-1/+1
Rename 'librustc_unicode' crate to 'libstd_unicode'. Fixes https://github.com/rust-lang/rust/issues/26554.
2016-11-30Move small-copy optimization into <&[u8] as Read>Ruud van Asseldonk-2/+20
Based on the discussion in https://github.com/rust-lang/rust/pull/37573, it is likely better to keep this limited to std::io, instead of modifying a function which users expect to be a memcpy.
2016-11-30Move small-copy optimization into copy_from_sliceRuud van Asseldonk-15/+3
Ultimately copy_from_slice is being a bottleneck, not io::Cursor::read. It might be worthwhile to move the check here, so more places can benefit from it.
2016-11-30Add small-copy optimization for io::CursorRuud van Asseldonk-3/+15
During benchmarking, I found that one of my programs spent between 5 and 10 percent of the time doing memmoves. Ultimately I tracked these down to single-byte slices being copied with a memcopy in io::Cursor::read(). Doing a manual copy if only one byte is requested can speed things up significantly. For my program, this reduced the running time by 20%. Why special-case only a single byte, and not a "small" slice in general? I tried doing this for slices of at most 64 bytes and of at most 8 bytes. In both cases my test program was significantly slower.
2016-11-30Rename 'librustc_unicode' crate to 'libstd_unicode'.Corey Farwell-1/+1
Fixes #26554.
2016-11-28Move stdout/err flush into sysJeremy Soller-6/+0
2016-11-28std: Fix partial writes in LineWriterAlex Crichton-13/+86
Previously the `LineWriter` could successfully write some bytes but then fail to report that it has done so. Additionally, an erroneous flush after a successful write was permanently ignored. This commit fixes these two issues by (a) maintaining a `need_flush` flag to indicate whether a flush should be the first operation in `LineWriter::write` and (b) avoiding returning an error once some bytes have been successfully written. Closes #37807
2016-11-19Merge branch 'master' into redoxJeremy Soller-1/+4
2016-11-10Merge branch 'master' into redoxJeremy Soller-34/+74
2016-11-10Fixes for stdio and processes on RedoxJeremy Soller-0/+6
2016-11-10Remove one bounds check from BufReaderArthur Silva-1/+4
Otherwise the optimizer can't be sure that pos <= cap. Added a paranoid debug_assert to ensure correctness instead.
2016-11-08Rollup merge of #37588 - GuillaumeGomez:missing_io_urls, r=frewsxcvSteve Klabnik-11/+19
Add missing urls on io structs r? @steveklabnik
2016-11-05Rollup merge of #37537 - GuillaumeGomez:error_kind_doc, r=steveklabnikAlex Crichton-2/+7
Add missing urls for ErrorKind's variants r? @steveklabnik
2016-11-05add missing urls on io structsGuillaume Gomez-11/+19
2016-11-04Auto merge of #37037 - Mark-Simulacrum:stack-error, r=alexcrichtonbors-21/+48
Add conversions from `io:ErrorKind` to `io::Error` Filing to help with discussion around the possibility of doing this. Current changes are clearly backwards incompatible, but I think adding a new function (with a bikeshed on naming) like `Error::new_str` should be possible (or some other way of specializing the string error message case) to fix #36658.
2016-11-02Add missing urls for ErrorKind's variantsGuillaume Gomez-2/+7
2016-11-02Auto merge of #36948 - brson:sys, r=brsonbors-10/+2
More refactoring to obey platform abstraction lint The most interesting things here are moving `std/sys/common` to `std/sys_common`, and `std/num/{f32,f64}.rs` to `std/{f32,f64}.rs`, and adding more documentation to `std/lib.rs`. r? @alexcrichton
2016-11-02Add a new non-heap allocated variant to io::Error's representation.Mark-Simulacrum-21/+48
Implement From<ErrorKind> for io::Error, intended for use with errors that should never be exposed to the user.
2016-11-01std: Move a plattform-specific constant to sys::stdioBrian Anderson-10/+2
2016-11-01Rollup merge of #37316 - ollie27:docs_links, r=GuillaumeGomezGuillaume Gomez-2/+2
Fix a few links in the docs r? @steveklabnik
2016-10-31Changed most vec! invocations to use square bracesiirelu-6/+6
Most of the Rust community agrees that the vec! macro is clearer when called using square brackets [] instead of regular brackets (). Most of these ocurrences are from before macros allowed using different types of brackets. There is one left unchanged in a pretty-print test, as the pretty printer still wants it to have regular brackets.
2016-10-27Add documentation for Read, Write impls for slices and VecUlrik Sverdrup-0/+11
The Write impls for &[u8] and Vec<u8> are quite different, and we need this to be reflected in the docs. These documentation comments will be visible on the respective type's page in the trait impls section.
2016-10-21Fix a few links in the docsOliver Middleton-2/+2
2016-10-19Rollup merge of #37165 - GuillaumeGomez:bytes_url, r=kmcallisterGuillaume Gomez-6/+12
Add missing urls for io types r? @steveklabnik