about summary refs log tree commit diff
path: root/src/libstd/io/mod.rs
AgeCommit message (Collapse)AuthorLines
2015-08-02Docs: clarify return value of std::io::Seek::seekSimon Sapin-2/+3
2015-07-29Rollup merge of #27327 - steveklabnik:fix_take, r=alexcrichtonSteve Klabnik-1/+1
This only reads five bytes, so don't use a ten byte buffer, that's confusing. r? @alexcrichton
2015-07-27std: Deprecate a number of unstable featuresAlex Crichton-1/+1
Many of these have long since reached their stage of being obsolete, so this commit starts the removal process for all of them. The unstable features that were deprecated are: * cmp_partial * fs_time * hash_default * int_slice * iter_min_max * iter_reset_fuse * iter_to_vec * map_in_place * move_from * owned_ascii_ext * page_size * read_and_zero * scan_state * slice_chars * slice_position_elem * subslice_offset
2015-07-27Fix buffer length in std::io::takeSteve Klabnik-1/+1
This only reads five bytes, so don't use a ten byte buffer, that's confusing.
2015-07-22Rollup merge of #27167 - steveklabnik:doc_std_io_take, r=alexcrichtonSteve Klabnik-2/+8
Better and more consistent links to their creators.
2015-07-22Rollup merge of #27157 - steveklabnik:doc_std_io_iterators, r=alexcrichtonSteve Klabnik-11/+28
Make them all consistent and link up the documentation. r? @alexcrichton
2015-07-20Write better docs for std::ioSteve Klabnik-0/+229
This is the landing page for all of io, so we should have more than just a sentence here.
2015-07-20Update docs for take and broadcastSteve Klabnik-2/+8
Better and more consistent links to their creators.
2015-07-20Document iterators in std::ioSteve Klabnik-11/+28
Make them all consistent and link up the documentation.
2015-07-16Merge branch 'doc_io_traits_enums' of https://github.com/steveklabnik/rust ↵Steve Klabnik-58/+601
into rollup_central
2015-07-16More docs for std::io free functions.Steve Klabnik-10/+10
2015-07-16More docs for std::io::WriteSteve Klabnik-12/+114
2015-07-16More docs for std::io::SeekSteve Klabnik-6/+27
2015-07-16More docs for std::io::ReadSteve Klabnik-12/+278
2015-07-16More docs for std::io::BufReadSteve Klabnik-32/+186
2015-07-15Add specializations of read_to_end for Stdin, TcpStream and File,Alisdair Owens-0/+11
allowing them to read into a buffer containing uninitialized data, rather than pay the cost of zeroing.
2015-07-08Improve Vec::resize so that it can be used in Read::read_to_endUlrik Sverdrup-2/+10
We needed a more efficient way to zerofill the vector in read_to_end. This to reduce the memory intialization overhead to a minimum. Use the implementation of `std::vec::from_elem` (used for the vec![] macro) for Vec::resize as well. For simple element types like u8, this compiles to memset, so it makes Vec::resize much more efficient.
2015-06-23doc: remove repeated wordTshepang Lekhonkhobe-1/+1
2015-05-29std::io: New ErrorKind value InvalidDataMikhail Zabaluev-1/+1
This takes the cases from InvalidInput where a data format error was encountered. This is different from the documented semantics of InvalidInput, which more likely indicate a programming error.
2015-05-27Use `const fn` to abstract away the contents of UnsafeCell & friends.Eduard Burtescu-2/+1
2015-05-25doc: fix io::Write::write typoTshepang Lekhonkhobe-1/+1
2015-05-19Add example code and cross-link to BufReader docsMatt Brubeck-1/+4
2015-05-10Update docs to stop referencing `BufReadExt`Corey Farwell-2/+2
2015-04-30Replaces instanced of 'an UTF' with 'a UTF'Corey Farwell-1/+1
Even spelled out, one would say 'a Universal Character Set'
2015-04-28Register new snapshotsTamir Duberstein-2/+1
2015-04-16deprecate Unicode functions that will be moved to crates.iokwantam-1/+1
This patch 1. renames libunicode to librustc_unicode, 2. deprecates several pieces of libunicode (see below), and 3. removes references to deprecated functions from librustc_driver and libsyntax. This may change pretty-printed output from these modules in cases involving wide or combining characters used in filenames, identifiers, etc. The following functions are marked deprecated: 1. char.width() and str.width(): --> use unicode-width crate 2. str.graphemes() and str.grapheme_indices(): --> use unicode-segmentation crate 3. str.nfd_chars(), str.nfkd_chars(), str.nfc_chars(), str.nfkc_chars(), char.compose(), char.decompose_canonical(), char.decompose_compatible(), char.canonical_combining_class(): --> use unicode-normalization crate
2015-04-16Auto merge of #23682 - tamird:DRY-is-empty, r=alexcrichtonbors-1/+1
r? @alexcrichton
2015-04-15Fix some typos.Ms2ger-1/+1
2015-04-14Negative case of `len()` -> `is_empty()`Tamir Duberstein-1/+1
`s/([^\(\s]+\.)len\(\) [(?:!=)>] 0/!$1is_empty()/g`
2015-04-14rollup merge of #24377: apasel422/docsAlex Crichton-6/+6
Conflicts: src/libstd/net/ip.rs src/libstd/sys/unix/fs.rs src/libstd/sys/unix/mod.rs src/libstd/sys/windows/mod.rs
2015-04-13Refine read_to_end documentationSimonas Kazlauskas-7/+4
2015-04-13pluralize doc comment verbs and add missing periodsAndrew Paseltiner-6/+6
2015-04-06Remove outdated notice from BufRead::lines docs.Matt Brubeck-3/+0
There is no `read_string` function, and `lines` never returns an error.
2015-04-02Rollup merge of #23847 - bcoopers:read_clarification, r=sfacklerManish Goregaokar-8/+4
This introduces no functional changes except for reducing a few unnecessary operations and variables. Vec has the behavior that, if you request space past the capacity with reserve(), it will round up to the nearest power of 2. What that effectively means is that after the first call to reserve(16), we are doubling our capacity every time. So using the DEFAULT_BUF_SIZE and doubling cap_size() here is meaningless and has no effect on the call to reserve(). Note that with #23842 implemented this will hopefully have a clearer API and less of a need for commenting. If #23842 is not implemented then the most clear implementation would be to call reserve_exact(buf.capacity()) at every step (and making sure that buf.capacity() is not zero at the beginning of the function of course). Edit- functional change now introduced. We will now zero 16 bytes of the vector first, then double to 32, then 64, etc. until we read 64kB. This stops us from zeroing the entire vector when we double it, some of which may be wasted work. Reallocation still follows the doubling strategy, but the responsibility has been moved to vec.extend(), which calls reserve() and push_back().
2015-03-31Test fixes and rebase conflicts, round 3Alex Crichton-24/+24
2015-03-31rollup merge of #23919: alexcrichton/stabilize-io-errorAlex Crichton-4/+3
Conflicts: src/libstd/fs/tempdir.rs src/libstd/io/error.rs
2015-03-31std: Stabilize last bits of io::ErrorAlex Crichton-4/+3
This commit stabilizes a few remaining bits of the `io::Error` type: * The `Error::new` method is now stable. The last `detail` parameter was removed and the second `desc` parameter was generalized to `E: Into<Box<Error>>` to allow creating an I/O error from any form of error. Currently there is no form of downcasting, but this will be added in time. * An implementation of `From<&str> for Box<Error>` was added to liballoc to allow construction of errors from raw strings. * The `Error::raw_os_error` method was stabilized as-is. * Trait impls for `Clone`, `Eq`, and `PartialEq` were removed from `Error` as it is not possible to use them with trait objects. This is a breaking change due to the modification of the `new` method as well as the removal of the trait implementations for the `Error` type. [breaking-change]
2015-03-31Stabilize a few remaining stragglersAaron Turon-4/+6
* The `io::Seek` trait, and `SeekFrom` enum. * The `Iterator::{partition, unsip}` methods. * The `Vec::into_boxed_slice` method. * The `LinkedList::append` method. * The `{or_insert, or_insert_with` methods in the `Entry` APIs.
2015-03-30Only zero at most 64k at a time. We still use the doublingbcoopers-8/+4
reallocation strategy since extend() calls reserve() and/or push() for us.
2015-03-29Clearer wordingbcoopers-3/+3
2015-03-2980 character line limitbcoopers-2/+3
2015-03-29Clarified and simplified algorithm for increasing size of buffer inbcoopers-5/+4
read_to_end()
2015-03-29Auto merge of #23820 - sfackler:fast_read_to_end, r=alexcrichtonbors-31/+33
with_end_to_cap is enormously expensive now that it's initializing memory since it involves 64k allocation + memset on every call. This is most noticable when calling read_to_end on very small readers, where the new version if **4 orders of magnitude** faster. BufReader also depended on with_end_to_cap so I've rewritten it in its original form. As a bonus, converted the buffered IO struct Debug impls to use the debug builders. I first came across this in sfackler/rust-postgres#106 where a user reported a 10x performance regression. A call to read_to_end turned out to be the culprit: https://github.com/sfackler/rust-postgres/commit/9cd413d42c287154d6c64cc7913666b0517f35f3. The new version differs from the old in a couple of ways. The buffer size used is now adaptive. It starts at 32 bytes and doubles each time EOF hasn't been reached up to a limit of 64k. In addition, the buffer is only truncated when EOF or an error has been reached, rather than after every call to read as was the case for the old implementation. I wrote up a benchmark to compare the old version and new version: https://gist.github.com/sfackler/e979711b0ee2f2063462 It tests a couple of different cases: a high bandwidth reader, a low bandwidth reader, and a low bandwidth reader that won't return more than 10k per call to `read`. The high bandwidth reader should be analagous to use cases when reading from e.g. a `BufReader` or `Vec`, and the low bandwidth readers should be analogous to reading from something like a `TcpStream`. Of special note, reads from a high bandwith reader containing 4 bytes are now *4,495 times faster*. ``` ~/foo ❯ cargo bench Compiling foo v0.0.1 (file:///home/sfackler/foo) Running target/release/foo-7498d7dd7faecf5c running 13 tests test test_new ... ignored test new_delay_4 ... bench: 230768 ns/iter (+/- 14812) test new_delay_4_cap ... bench: 231421 ns/iter (+/- 7211) test new_delay_5m ... bench: 14495370 ns/iter (+/- 4008648) test new_delay_5m_cap ... bench: 73127954 ns/iter (+/- 59908587) test new_nodelay_4 ... bench: 83 ns/iter (+/- 2) test new_nodelay_5m ... bench: 12527237 ns/iter (+/- 335243) test std_delay_4 ... bench: 373095 ns/iter (+/- 12613) test std_delay_4_cap ... bench: 374190 ns/iter (+/- 19611) test std_delay_5m ... bench: 17356012 ns/iter (+/- 15906588) test std_delay_5m_cap ... bench: 883555035 ns/iter (+/- 205559857) test std_nodelay_4 ... bench: 144937 ns/iter (+/- 2448) test std_nodelay_5m ... bench: 16095893 ns/iter (+/- 3315116) test result: ok. 0 passed; 0 failed; 1 ignored; 12 measured ``` r? @alexcrichton
2015-03-28Fix massive performance issue in read_to_endSteven Fackler-31/+33
with_end_to_cap is enormously expensive now that it's initializing memory since it involves 64k allocation + memset on every call. This is most noticable when calling read_to_end on very small readers, where the new version if **4 orders of magnitude** faster. BufReader also depended on with_end_to_cap so I've rewritten it in its original form. As a bonus, converted the buffered IO struct Debug impls to use the debug builders. Fixes #23815
2015-03-28Remove IteratorExtSteven Fackler-1/+1
All methods are inlined into Iterator with `Self: Sized` bounds to make sure Iterator is still object safe. [breaking-change]
2015-03-26std: Stabilize BufRead::splitAlex Crichton-4/+3
Now that `<[_]>::split` is an inherent method, it will trump `BufRead::split` when `BufRead` is in scope, so there is no longer a conflict. As a result, calling `slice.split()` will probably always give you precisely what you want!
2015-03-25Rollup merge of #23664 - bluss:std-docs, r=steveklabnikManish Goregaokar-15/+15
Main motivation was to update docs for the removal or "demotion" of certain extension traits. The update to the slice docs was larger, since the text was largely outdated.
2015-03-24rollup merge of #23668: alexcrichton/io-zeroAlex Crichton-30/+14
This commit alters the behavior of the `Read::read_to_end()` method to zero all memory instead of passing an uninitialized buffer to `read`. This change is motivated by the [discussion on the internals forum][discuss] where the conclusion has been that the standard library will not expose uninitialized memory. [discuss]: http://internals.rust-lang.org/t/uninitialized-memory/1652 Closes #20314
2015-03-24std: Update docs for removal of ReadExt, WriteExtUlrik Sverdrup-15/+15
2015-03-24std: Zero memory when calling `read_to_end()`Alex Crichton-30/+14
This commit alters the behavior of the `Read::read_to_end()` method to zero all memory instead of passing an uninitialized buffer to `read`. This change is motivated by the [discussion on the internals forum][discuss] where the conclusion has been that the standard library will not expose uninitialized memory. [discuss]: http://internals.rust-lang.org/t/uninitialized-memory/1652 Closes #20314