about summary refs log tree commit diff
path: root/src/libstd/io/mod.rs
AgeCommit message (Collapse)AuthorLines
2015-03-23Beef up BufRead::consume documentation.Steve Klabnik-0/+6
Fixes #23196
2015-03-20Rollup merge of #23499 - mbrubeck:doc-edit, r=huonwManish Goregaokar-1/+2
Multiple people have been suprised by this aspect of read_line's behavior, which is not obvious from the docs.
2015-03-18Clarify in docs that BufRead::read_line appendsMatt Brubeck-1/+2
Multiple people have been suprised by this aspect of read_line's behavior, which is not obvious from the docs.
2015-03-18Register new snapshotsAlex Crichton-8/+0
2015-03-18Remove the newly introduced trait impls for fixed-size arrays and use ↵Vadim Petrochenkov-13/+13
&b"..."[..] instead.
2015-03-17Rollup merge of #23415 - alexcrichton:stabilize-flush, r=aturonManish Goregaokar-1/+1
The [associated RFC][rfc] for possibly splitting out `flush` has been closed and as a result there are no more blockers for stabilizing this method, so this commit marks the method as such. [rfc]: https://github.com/rust-lang/rfcs/pull/950
2015-03-16impl<T> *const T, impl<T> *mut TJorge Aparicio-0/+1
2015-03-16impl<T> [T]Jorge Aparicio-0/+3
2015-03-16impl strJorge Aparicio-0/+3
2015-03-16std: Stabilize the Write::flush methodAlex Crichton-1/+1
The [associated RFC][rfc] for possibly splitting out `flush` has been closed and as a result there are no more blockers for stabilizing this method, so this commit marks the method as such. [rfc]: https://github.com/rust-lang/rfcs/pull/950
2015-03-15Auto merge of #23206 - nagisa:print-io, r=alexcrichtonbors-2/+2
r? @alexcrichton or @aturon This still needs to somehow figure out how to avoid unstable warnings arising from the use of unstable functions. I tried to use `#[allow_internal_unstable]` but it still spits out warnings as far as I can see. @huonw (I think you implemented it) does `#[allow_internal_unstable]` not work for some reason or am I using it incorrectly?
2015-03-14Stop recommending old_io in the module doc for std::ioKevin Ballard-4/+0
Now that `old_io` is deprecated and `std::io` is stable, we should stop recommending the use of `old_io` in the module documentation.
2015-03-15Use new io in print and println macrosesSimonas Kazlauskas-2/+2
2015-03-13Fallout of std::old_io deprecationAlex Crichton-12/+14
2015-03-12std: Stabilize the `io` moduleAlex Crichton-58/+78
The new `std::io` module has had some time to bake now, and this commit stabilizes its functionality. There are still portions of the module which remain unstable, and below contains a summart of the actions taken. This commit also deprecates the entire contents of the `old_io` module in a blanket fashion. All APIs should now have a reasonable replacement in the new I/O modules. Stable APIs: * `std::io` (the name) * `std::io::prelude` (the name) * `Read` * `Read::read` * `Read::{read_to_end, read_to_string}` after being modified to return a `usize` for the number of bytes read. * `Write` * `Write::write` * `Write::{write_all, write_fmt}` * `BufRead` * `BufRead::{fill_buf, consume}` * `BufRead::{read_line, read_until}` after being modified to return a `usize` for the number of bytes read. * `BufReader` * `BufReader::{new, with_capacity}` * `BufReader::{get_ref, get_mut, into_inner}` * `{Read,BufRead} for BufReader` * `BufWriter` * `BufWriter::{new, with_capacity}` * `BufWriter::{get_ref, get_mut, into_inner}` * `Write for BufWriter` * `IntoInnerError` * `IntoInnerError::{error, into_inner}` * `{Error,Display} for IntoInnerError` * `LineWriter` * `LineWriter::{new, with_capacity}` - `with_capacity` was added * `LineWriter::{get_ref, get_mut, into_inner}` - `get_mut` was added) * `Write for LineWriter` * `BufStream` * `BufStream::{new, with_capacities}` * `BufStream::{get_ref, get_mut, into_inner}` * `{BufRead,Read,Write} for BufStream` * `stdin` * `Stdin` * `Stdin::lock` * `Stdin::read_line` - added method * `StdinLock` * `Read for Stdin` * `{Read,BufRead} for StdinLock` * `stdout` * `Stdout` * `Stdout::lock` * `StdoutLock` * `Write for Stdout` * `Write for StdoutLock` * `stderr` * `Stderr` * `Stderr::lock` * `StderrLock` * `Write for Stderr` * `Write for StderrLock` * `io::Result` * `io::Error` * `io::Error::last_os_error` * `{Display, Error} for Error` Unstable APIs: (reasons can be found in the commit itself) * `Write::flush` * `Seek` * `ErrorKind` * `Error::new` * `Error::from_os_error` * `Error::kind` Deprecated APIs * `Error::description` - available via the `Error` trait * `Error::detail` - available via the `Display` implementation * `thread::Builder::{stdout, stderr}` Changes in functionality: * `old_io::stdio::set_stderr` is now a noop as the infrastructure for printing backtraces has migrated to `std::io`. * The `ReadExt`, `WriteExt`, and `BufReadExt` extension traits were all removed by folding functionality into the corresponding trait. [breaking-change]
2015-03-06Rollup merge of #23010 - alexcrichton:deprecate-some-old-io, r=aturonManish Goregaokar-0/+32
The new `io` module has had some time to bake and this commit stabilizes some of the utilities associated with it. This commit also deprecates a number of `std::old_io::util` functions and structures. These items are now `#[stable]` * `Cursor` * `Cursor::{new, into_inner, get_ref, get_mut, position, set_position}` * Implementations of I/O traits for `Cursor<T>` * Delegating implementations of I/O traits for references and `Box` pointers * Implementations of I/O traits for primitives like slices and `Vec<T>` * `ReadExt::bytes` * `Bytes` (and impls) * `ReadExt::chain` * `Chain` (and impls) * `ReadExt::take` (and impls) * `BufReadExt::lines` * `Lines` (and impls) * `io::copy` * `io::{empty, Empty}` (and impls) * `io::{sink, Sink}` (and impls) * `io::{repeat, Repeat}` (and impls) These items remain `#[unstable]` * Core I/O traits. These may want a little bit more time to bake along with the commonly used methods like `read_to_end`. * `BufReadExt::split` - this function may be renamed to not conflict with `SliceExt::split`. * `Error` - there are a number of questions about its representation, `ErrorKind`, and usability. These items are now `#[deprecated]` in `old_io` * `LimitReader` - use `take` instead * `NullWriter` - use `io::sink` instead * `ZeroReader` - use `io::repeat` instead * `NullReader` - use `io::empty` instead * `MultiWriter` - use `broadcast` instead * `ChainedReader` - use `chain` instead * `TeeReader` - use `tee` instead * `copy` - use `io::copy` instead [breaking-change]
2015-03-04std: Stabilize portions of the `io` moduleAlex Crichton-0/+32
The new `io` module has had some time to bake and this commit stabilizes some of the utilities associated with it. This commit also deprecates a number of `std::old_io::util` functions and structures. These items are now `#[stable]` * `Cursor` * `Cursor::{new, into_inner, get_ref, get_mut, position, set_position}` * Implementations of I/O traits for `Cursor<T>` * Delegating implementations of I/O traits for references and `Box` pointers * Implementations of I/O traits for primitives like slices and `Vec<T>` * `ReadExt::bytes` * `Bytes` (and impls) * `ReadExt::chain` * `Chain` (and impls) * `ReadExt::take` (and impls) * `BufReadExt::lines` * `Lines` (and impls) * `io::copy` * `io::{empty, Empty}` (and impls) * `io::{sink, Sink}` (and impls) * `io::{repeat, Repeat}` (and impls) These items remain `#[unstable]` * Core I/O traits. These may want a little bit more time to bake along with the commonly used methods like `read_to_end`. * `BufReadExt::split` - this function may be renamed to not conflict with `SliceExt::split`. * `Error` - there are a number of questions about its representation, `ErrorKind`, and usability. These items are now `#[deprecated]` in `old_io` * `LimitReader` - use `take` instead * `NullWriter` - use `io::sink` instead * `ZeroReader` - use `io::repeat` instead * `NullReader` - use `io::empty` instead * `MultiWriter` - use `broadcast` instead * `ChainedReader` - use `chain` instead * `TeeReader` - use `tee` instead * `copy` - use `io::copy` instead [breaking-change]
2015-03-04Auto merge of #22920 - tshepang:remove-some-warnings, r=huonwbors-1/+1
2015-03-01remove some compiler warningsTshepang Lekhonkhobe-1/+1
2015-02-28std: Implement stdio for `std::io`Alex Crichton-0/+5
This is an implementation of RFC 899 and adds stdio functionality to the new `std::io` module. Details of the API can be found on the RFC, but from a high level: * `io::{stdin, stdout, stderr}` constructors are now available. There are also `*_raw` variants for unbuffered and unlocked access. * All handles are globally shared (excluding raw variants). * The stderr handle is no longer buffered. * All handles can be explicitly locked (excluding the raw variants). The `print!` and `println!` machinery has not yet been hooked up to these streams just yet. The `std::fmt::output` module has also not yet been implemented as part of this commit.
2015-02-23Rollup merge of #22640 - sfackler:fix-take, r=alexcrichtonManish Goregaokar-0/+35
We can't call into the inner reader for a 0-byte read because that may end up blocking or returning an error. r? @alexcrichton
2015-02-21Implement BufRead for TakeSteven Fackler-0/+15
2015-02-22Rollup merge of #22567 - Gankro:unstable, r=alexcrichtonManish Goregaokar-4/+4
* Adds features and allows * Removes unused muts, unused imports, dead code * Migrates some deprecated code to new io/env * Changes std::num::uint/int to be re-exports of std::num::usize/isize libcollections, liballoc, and libcoretest no longer warn during testing. libstd warns much less, though there's some dangly bits that weren't obvious fixes. In particular, how to only supress deprecated warnings in specific submodules of std.
2015-02-21Fix io::Take behavior with limit 0Steven Fackler-0/+20
We can't call into the inner reader for a 0-byte read because that may end up blocking or returning an error.
2015-02-21Fix typo in std::io unstable reasonJake Goulding-1/+1
2015-02-20try to reduce bajillion warningsAlexis-4/+4
2015-02-17Rollup merge of #22311 - lfairy:consistent-fmt, r=alexcrichtonManish Goregaokar-2/+2
This brings it in line with its namesake in `std::io`. [breaking-change] r? @aturon
2015-02-16Make io::Seek docs less prescriptiveSteven Fackler-3/+2
2015-02-14Rename `fmt::Writer` to `fmt::Write`Chris Wong-2/+2
This brings it in line with its namesake in `std::io`. [breaking-change]
2015-02-06Rollup merge of #21926 - mzabaluev:raw-lifetime, r=alexcrichtonManish Goregaokar-3/+2
New functions, `slice::from_raw_parts` and `slice::from_raw_parts_mut`, are added to implement the lifetime convention as agreed in rust-lang/rfcs#556. The functions `slice::from_raw_buf` and `slice::from_raw_mut_buf` are left deprecated for the time being. Holding back on changing the signature of `std::ffi::c_str_to_bytes` as consensus in rust-lang/rfcs#592 is building to replace it with a composition of other functions. Contribution to #21923.
2015-02-05Replace one more slice::from_raw_mut_buf added with new ioMikhail Zabaluev-3/+2
2015-02-04Fix for misspelled comments.Joseph Crail-2/+2
The spelling corrections were made in both documentation comments and regular comments.
2015-02-03std: Add `io` module againAlex Crichton-0/+948
This commit is an implementation of [RFC 576][rfc] which adds back the `std::io` module to the standard library. No functionality in `std::old_io` has been deprecated just yet, and the new `std::io` module is behind the same `io` feature gate. [rfc]: https://github.com/rust-lang/rfcs/pull/576 A good bit of functionality was copied over from `std::old_io`, but many tweaks were required for the new method signatures. Behavior such as precisely when buffered objects call to the underlying object may have been tweaked slightly in the transition. All implementations were audited to use composition wherever possible. For example the custom `pos` and `cap` cursors in `BufReader` were removed in favor of just using `Cursor<Vec<u8>>`. A few liberties were taken during this implementation which were not explicitly spelled out in the RFC: * The old `LineBufferedWriter` is now named `LineWriter` * The internal representation of `Error` now favors OS error codes (a 0-allocation path) and contains a `Box` for extra semantic data. * The io prelude currently reexports `Seek` as `NewSeek` to prevent conflicts with the real prelude reexport of `old_io::Seek` * The `chars` method was moved from `BufReadExt` to `ReadExt`. * The `chars` iterator returns a custom error with a variant that explains that the data was not valid UTF-8.
2015-01-26std: Rename io to old_ioAlex Crichton-1939/+0
In preparation for the I/O rejuvination of the standard library, this commit renames the current `io` module to `old_io` in order to make room for the new I/O modules. It is expected that the I/O RFCs will land incrementally over time instead of all at once, and this provides a fresh clean path for new modules to enter into as well as guaranteeing that all old infrastructure will remain in place for some time. As each `old_io` module is replaced it will be deprecated in-place for new structures in `std::{io, fs, net}` (as appropriate). This commit does *not* leave a reexport of `old_io as io` as the deprecation lint does not currently warn on this form of use. This is quite a large breaking change for all imports in existing code, but all functionality is retained precisely as-is and path statements simply need to be renamed from `io` to `old_io`. [breaking-change]
2015-01-21rollup merge of #21258: aturon/stab-3-indexAlex Crichton-2/+2
Conflicts: src/libcore/ops.rs src/librustc_typeck/astconv.rs src/libstd/io/mem.rs src/libsyntax/parse/lexer/mod.rs
2015-01-21Test fixes and rebase conflictsAlex Crichton-1/+1
2015-01-21rollup merge of #21457: alexcrichton/issue-21436Alex Crichton-24/+8
Conflicts: src/liballoc/boxed.rs src/librustc/middle/traits/error_reporting.rs src/libstd/sync/mpsc/mod.rs
2015-01-21rollup merge of #21423: oli-obk/prettier_read_untilAlex Crichton-10/+8
Conflicts: src/libstd/io/mod.rs
2015-01-21rollup merge of #21396: japaric/no-parens-in-rangeAlex Crichton-1/+1
Conflicts: src/libsyntax/parse/lexer/comments.rs
2015-01-21Fallout from stabilization.Aaron Turon-2/+2
2015-01-20std: Rename Show/String to Debug/DisplayAlex Crichton-24/+8
This commit is an implementation of [RFC 565][rfc] which is a stabilization of the `std::fmt` module and the implementations of various formatting traits. Specifically, the following changes were performed: [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0565-show-string-guidelines.md * The `Show` trait is now deprecated, it was renamed to `Debug` * The `String` trait is now deprecated, it was renamed to `Display` * Many `Debug` and `Display` implementations were audited in accordance with the RFC and audited implementations now have the `#[stable]` attribute * Integers and floats no longer print a suffix * Smart pointers no longer print details that they are a smart pointer * Paths with `Debug` are now quoted and escape characters * The `unwrap` methods on `Result` now require `Display` instead of `Debug` * The `Error` trait no longer has a `detail` method and now requires that `Display` must be implemented. With the loss of `String`, this has moved into libcore. * `impl<E: Error> FromError<E> for Box<Error>` now exists * `derive(Show)` has been renamed to `derive(Debug)`. This is not currently warned about due to warnings being emitted on stage1+ While backwards compatibility is attempted to be maintained with a blanket implementation of `Display` for the old `String` trait (and the same for `Show`/`Debug`) this is still a breaking change due to primitives no longer implementing `String` as well as modifications such as `unwrap` and the `Error` trait. Most code is fairly straightforward to update with a rename or tweaks of method calls. [breaking-change] Closes #21436
2015-01-21Rollup merge of #21312 - michaelsproul:remove-error-send-bound, r=aturonBarosl LEE-3/+3
As discussed with @aturon, this PR removes the `Send` bound from `std::error::Error`, allowing us to implement `Error` for error types containing non-`Send` types. Current examples include `PoisonError` and `TryLockError` from `std::sync` which contain a Guard that we don't want sent between tasks. [breaking-change]
2015-01-20prettier Buffer::read_untilOliver Schneider-10/+8
2015-01-19remove unnecessary parentheses from range notationJorge Aparicio-1/+1
2015-01-17Remove Send bound from Error trait.Michael Sproul-3/+3
2015-01-17Evaluate # fn in docsSteve Klabnik-16/+11
I searched for times when we were hiding functions with # in the documentation, and fixed them to not use it unless neccesary. I also made random improvements whenever I changed something. For example, I changed Example to Examples, for consistency. Fixes #13423
2015-01-12cleanup: `&foo[0..a]` -> `&foo[..a]`Jorge Aparicio-3/+3
2015-01-08Improvements to feature stagingBrian Anderson-1/+1
This gets rid of the 'experimental' level, removes the non-staged_api case (i.e. stability levels for out-of-tree crates), and lets the staged_api attributes use 'unstable' and 'deprecated' lints. This makes the transition period to the full feature staging design a bit nicer.
2015-01-07Test fixes and rebase conflictsAlex Crichton-1/+1
2015-01-07use slicing sugarJorge Aparicio-4/+4