about summary refs log tree commit diff
path: root/src/libstd/io/mod.rs
AgeCommit message (Collapse)AuthorLines
2014-02-28std: Change assert_eq!() to use {} instead of {:?}Alex Crichton-1/+1
Formatting via reflection has been a little questionable for some time now, and it's a little unfortunate that one of the standard macros will silently use reflection when you weren't expecting it. This adds small bits of code bloat to libraries, as well as not always being necessary. In light of this information, this commit switches assert_eq!() to using {} in the error message instead of {:?}. In updating existing code, there were a few error cases that I encountered: * It's impossible to define Show for [T, ..N]. I think DST will alleviate this because we can define Show for [T]. * A few types here and there just needed a #[deriving(Show)] * Type parameters needed a Show bound, I often moved this to `assert!(a == b)` * `Path` doesn't implement `Show`, so assert_eq!() cannot be used on two paths. I don't think this is much of a regression though because {:?} on paths looks awful (it's a byte array). Concretely speaking, this shaved 10K off a 656K binary. Not a lot, but sometime significant for smaller binaries.
2014-02-28std: Improve some I/O documentationAlex Crichton-11/+126
This lowers the #[allow(missing_doc)] directive into some of the lower modules which are less mature. Most I/O modules now require comprehensive documentation.
2014-02-26auto merge of #12490 : zslayton/rust/doc-fix-12386, r=alexcrichtonbors-14/+0
Attn: @huonw Addresses #12386.
2014-02-24auto merge of #12412 : alexcrichton/rust/deriving-show, r=huonwbors-41/+1
This commit removes deriving(ToStr) in favor of deriving(Show), migrating all impls of ToStr to fmt::Show. Most of the details can be found in the first commit message. Closes #12477
2014-02-23auto merge of #12380 : alexcrichton/rust/run-rewrite, r=brsonbors-1/+1
The std::run module is a relic from a standard library long since past, and there's not much use to having two modules to execute processes with where one is slightly more convenient. This commit merges the two modules, moving lots of functionality from std::run into std::io::process and then deleting std::run. New things you can find in std::io::process are: * Process::new() now only takes prog/args * Process::configure() takes a ProcessConfig * Process::status() is the same as run::process_status * Process::output() is the same as run::process_output * I/O for spawned tasks is now defaulted to captured in pipes instead of ignored * Process::kill() was added (plus an associated green/native implementation) * Process::wait_with_output() is the same as the old finish_with_output() * destroy() is now signal_exit() * force_destroy() is now signal_kill() Closes #2625 Closes #10016
2014-02-23Roll std::run into std::io::processAlex Crichton-1/+1
The std::run module is a relic from a standard library long since past, and there's not much use to having two modules to execute processes with where one is slightly more convenient. This commit merges the two modules, moving lots of functionality from std::run into std::io::process and then deleting std::run. New things you can find in std::io::process are: * Process::new() now only takes prog/args * Process::configure() takes a ProcessConfig * Process::status() is the same as run::process_status * Process::output() is the same as run::process_output * I/O for spawned tasks is now defaulted to captured in pipes instead of ignored * Process::kill() was added (plus an associated green/native implementation) * Process::wait_with_output() is the same as the old finish_with_output() * destroy() is now signal_exit() * force_destroy() is now signal_kill() Closes #2625 Closes #10016
2014-02-23Remove all ToStr impls, add Show implsAlex Crichton-41/+1
This commit changes the ToStr trait to: impl<T: fmt::Show> ToStr for T { fn to_str(&self) -> ~str { format!("{}", *self) } } The ToStr trait has been on the chopping block for quite awhile now, and this is the final nail in its coffin. The trait and the corresponding method are not being removed as part of this commit, but rather any implementations of the `ToStr` trait are being forbidden because of the generic impl. The new way to get the `to_str()` method to work is to implement `fmt::Show`. Formatting into a `&mut Writer` (as `format!` does) is much more efficient than `ToStr` when building up large strings. The `ToStr` trait forces many intermediate allocations to be made while the `fmt::Show` trait allows incremental buildup in the same heap allocated buffer. Additionally, the `fmt::Show` trait is much more extensible in terms of interoperation with other `Writer` instances and in more situations. By design the `ToStr` trait requires at least one allocation whereas the `fmt::Show` trait does not require any allocations. Closes #8242 Closes #9806
2014-02-23Closes #12386. Removed 'pub mod' doc-comments in std::io's mod.rs file. ↵zslayton-14/+0
Added summary doc-comments to test.rs, util.rs and stdio.rs.
2014-02-22std: Remove some nonsense from old std::io docsBrian Anderson-126/+41
Most of this stuff is irrelevant implementation notes from last year. This trims out the stuff that isn't appropriate for user-facing docs.
2014-02-21auto merge of #12422 : alexcrichton/rust/buffered-default, r=brsonbors-7/+4
One of the most common ways to use the stdin stream is to read it line by line for a small program. In order to facilitate this common usage pattern, this commit changes the stdin() function to return a BufferedReader by default. A new `stdin_raw()` method was added to get access to the raw unbuffered stream. I have not changed the stdout or stderr methods because they are currently unable to flush in their destructor, but #12403 should have just fixed that.
2014-02-22Reduce reliance on `to_str_radix`Brendan Zabarauskas-2/+2
This is in preparation to remove the implementations of ToStrRadix in integers, and to remove the associated logic from `std::num::strconv`. The parts that still need to be liberated are: - `std::fmt::Formatter::runplural` - `num::{bigint, complex, rational}`
2014-02-20Mass rename if_ok! to try!Alex Crichton-5/+5
This "bubble up an error" macro was originally named if_ok! in order to get it landed, but after the fact it was discovered that this name is not exactly desirable. The name `if_ok!` isn't immediately clear that is has much to do with error handling, and it doesn't look fantastic in all contexts (if if_ok!(...) {}). In general, the agreed opinion about `if_ok!` is that is came in as subpar. The name `try!` is more invocative of error handling, it's shorter by 2 letters, and it looks fitting in almost all circumstances. One concern about the word `try!` is that it's too invocative of exceptions, but the belief is that this will be overcome with documentation and examples. Close #12037
2014-02-20Return a buffered stdin by default.Alex Crichton-7/+4
One of the most common ways to use the stdin stream is to read it line by line for a small program. In order to facilitate this common usage pattern, this commit changes the stdin() function to return a BufferedReader by default. A new `stdin_raw()` method was added to get access to the raw unbuffered stream. I have not changed the stdout or stderr methods because they are currently unable to flush in their destructor, but #12403 should have just fixed that.
2014-02-18Spellcheck library docs.Huon Wilson-1/+1
2014-02-15Create RefReader and RefWriter adaptor structsPalmer Cox-0/+33
RefReader and RefWriter allow a caller to pass a Reader or Writer instance by reference to generic functions that are expecting arguments by value.
2014-02-12auto merge of #12204 : alexcrichton/rust/seek, r=pcwaltonbors-5/+7
This adopts the rules posted in #10432: 1. If a seek position is negative, then an error is generated 2. Seeks beyond the end-of-file are allowed. Future writes will fill the gap with data and future reads will return errors. 3. Seeks within the bounds of a file are fine. Closes #10432
2014-02-11Finalize the Seek APIAlex Crichton-5/+7
This adopts the rules posted in #10432: 1. If a seek position is negative, then an error is generated 2. Seeks beyond the end-of-file are allowed. Future writes will fill the gap with data and future reads will return errors. 3. Seeks within the bounds of a file are fine. Closes #10432
2014-02-11std -- replaces uses where const borrows would be requiredNiko Matsakis-17/+25
2014-02-09std::io: Add `Chars` iterator for Buffer.gifnksm-0/+35
Add `std::io::Chars` iterator and `Buffer#chars()` method
2014-02-08std::fmt: convert the formatting traits to a proper self.Huon Wilson-3/+3
Poly and String have polymorphic `impl`s and so require different method names.
2014-02-03Fixing remaining warnings and errors throughoutAlex Crichton-4/+6
2014-02-03std: Fixing all documentationAlex Crichton-149/+138
* Stop referencing io_error * Start changing "Failure" sections to "Error" sections * Update all doc examples to work.
2014-02-03std: Fix tests with io_error usageAlex Crichton-11/+8
2014-02-03std: Remove io::io_errorAlex Crichton-243/+197
* All I/O now returns IoResult<T> = Result<T, IoError> * All formatting traits now return fmt::Result = IoResult<()> * The if_ok!() macro was added to libstd
2014-01-31Fix minor doc typosVirgile Andreani-1/+1
2014-01-28Rename OwnedCopyableVector to OwnedCloneableVectorVirgile Andreani-1/+1
2014-01-26Removed all instances of XXX in preparation for relaxing of FIXME ruleSalem Talha-12/+12
2014-01-25auto merge of #11808 : huonw/rust/std-visible-types, r=brsonbors-1/+1
These are either returned from public functions, and really should appear in the documentation, but don't since they're private, or are implementation details that are currently public.
2014-01-26std,extra: Make some types public and other private.Huon Wilson-1/+1
These are either returned from public functions, and really should appear in the documentation, but don't since they're private, or are implementation details that are currently public.
2014-01-25Uppercase numeric constantsChris Wong-9/+9
The following are renamed: * `min_value` => `MIN` * `max_value` => `MAX` * `bits` => `BITS` * `bytes` => `BYTES` Fixes #10010.
2014-01-21[std::str] Rename from_utf8_owned_opt() to from_utf8_owned(), drop the old ↵Simon Sapin-2/+2
from_utf8_owned() behavior
2014-01-21[std::str] Rename from_utf8_opt() to from_utf8(), drop the old from_utf8() ↵Simon Sapin-1/+1
behavior
2014-01-18Rename iterators for consistencyPalmer Cox-11/+11
Rename existing iterators to get rid of the Iterator suffix and to give them names that better describe the things being iterated over.
2014-01-17auto merge of #11598 : alexcrichton/rust/io-export, r=brsonbors-12/+15
* Reexport io::mem and io::buffered structs directly under io, make mem/buffered private modules * Remove with_mem_writer * Remove DEFAULT_CAPACITY and use DEFAULT_BUF_SIZE (in io::buffered) cc #11119
2014-01-17Tweak the interface of std::ioAlex Crichton-12/+15
* Reexport io::mem and io::buffered structs directly under io, make mem/buffered private modules * Remove with_mem_writer * Remove DEFAULT_CAPACITY and use DEFAULT_BUF_SIZE (in io::buffered)
2014-01-14Mark LineIterator as public so its docs get generated.a_m0d-1/+1
2014-01-11Remove re-exports of std::io::stdio::{print, println} in the prelude.Brendan Zabarauskas-3/+3
The `print!` and `println!` macros are now the preferred method of printing, and so there is no reason to export the `stdio` functions in the prelude. The functions have also been replaced by their macro counterparts in the tutorial and other documentation so that newcomers don't get confused about what they should be using.
2014-01-09Remove eof() from io::ReaderAlex Crichton-22/+0
2014-01-08Remove the io::Decorator traitAlex Crichton-27/+0
This is just an unnecessary trait that no one's ever going to parameterize over and it's more useful to just define the methods directly on the types themselves. The implementors of this type almost always don't want inner_mut_ref() but they're forced to define it as well.
2014-01-08Robustly read remaining bytes in a characterAlex Crichton-3/+9
Closes #11372
2014-01-06Remove some unnecessary type castsFlorian Hahn-5/+5
Conflicts: src/librustc/middle/lint.rs
2014-01-04auto merge of #11310 : Dretch/rust/write_char, r=alexcrichtonbors-0/+8
2014-01-04auto merge of #11271 : adridu59/rust/patch-io, r=huonwbors-21/+45
2014-01-04Restore Writer.write_char, see #10861.Gareth Smith-0/+8
2014-01-04std: io: add some code examplesAdrien Tétar-21/+45
Closes #11232.
2014-01-03Add read_to_str and write_{str, line}Alex Crichton-24/+53
These methods are sorely needed on readers and writers, and I believe that the encoding story should be solved with composition. This commit adds back the missed functions when reading/writing strings onto generic Readers/Writers.
2014-01-01Don't leave lingering files in doc testsAlex Crichton-0/+2
Closes #11234
2013-12-24rustuv: Get all tests passing again after refactorAlex Crichton-3/+2
All tests except for the homing tests are now working again with the librustuv/libgreen refactoring. The homing-related tests are currently commented out and now placed in the rustuv::homing module. I plan on refactoring scheduler pool spawning in order to enable more homing tests in a future commit.
2013-12-24std: Get stdtest all passing againAlex Crichton-0/+4
This commit brings the library up-to-date in order to get all tests passing again
2013-12-24native: Introduce libnativeAlex Crichton-5/+0
This commit introduces a new crate called "native" which will be the crate that implements the 1:1 runtime of rust. This currently entails having an implementation of std::rt::Runtime inside of libnative as well as moving all of the native I/O implementations to libnative. The current snag is that the start lang item must currently be defined in libnative in order to start running, but this will change in the future. Cool fact about this crate, there are no extra features that are enabled. Note that this commit does not include any makefile support necessary for building libnative, that's all coming in a later commit.