about summary refs log tree commit diff
path: root/src/libstd/io/stdio.rs
AgeCommit message (Collapse)AuthorLines
2014-10-29Rename fail! to panic!Steve Klabnik-4/+4
https://github.com/rust-lang/rfcs/pull/221 The current terminology of "task failure" often causes problems when writing or speaking about code. You often want to talk about the possibility of an operation that returns a Result "failing", but cannot because of the ambiguity with task failure. Instead, you have to speak of "the failing case" or "when the operation does not succeed" or other circumlocutions. Likewise, we use a "Failure" header in rustdoc to describe when operations may fail the task, but it would often be helpful to separate out a section describing the "Err-producing" case. We have been steadily moving away from task failure and toward Result as an error-handling mechanism, so we should optimize our terminology accordingly: Result-producing functions should be easy to describe. To update your code, rename any call to `fail!` to `panic!` instead. Assuming you have not created your own macro named `panic!`, this will work on UNIX based systems: grep -lZR 'fail!' . | xargs -0 -l sed -i -e 's/fail!/panic!/g' You can of course also do this by hand. [breaking-change]
2014-10-13Clean up rustc warnings.NODA, Kai-1/+4
compiletest: compact "linux" "macos" etc.as "unix". liballoc: remove a superfluous "use". libcollections: remove invocations of deprecated methods in favor of their suggested replacements and use "_" for a loop counter. libcoretest: remove invocations of deprecated methods; also add "allow(deprecated)" for testing a deprecated method itself. libglob: use "cfg_attr". libgraphviz: add a test for one of data constructors. libgreen: remove a superfluous "use". libnum: "allow(type_overflow)" for type cast into u8 in a test code. librustc: names of static variables should be in upper case. libserialize: v[i] instead of get(). libstd/ascii: to_lowercase() instead of to_lower(). libstd/bitflags: modify AnotherSetOfFlags to use i8 as its backend. It will serve better for testing various aspects of bitflags!. libstd/collections: "allow(deprecated)" for testing a deprecated method itself. libstd/io: remove invocations of deprecated methods and superfluous "use". Also add #[test] where it was missing. libstd/num: introduce a helper function to effectively remove invocations of a deprecated method. libstd/path and rand: remove invocations of deprecated methods and superfluous "use". libstd/task and libsync/comm: "allow(deprecated)" for testing a deprecated method itself. libsync/deque: remove superfluous "unsafe". libsync/mutex and once: names of static variables should be in upper case. libterm: introduce a helper function to effectively remove invocations of a deprecated method. We still see a few warnings about using obsoleted native::task::spawn() in the test modules for libsync. I'm not sure how I should replace them with std::task::TaksBuilder and native::task::NativeTaskBuilder (dependency to libstd?) Signed-off-by: NODA, Kai <nodakai@gmail.com>
2014-10-01Remove iotest macroAaron Turon-6/+9
This commit removes the `iotest!` macro from `std::io`. The macro was primarily used to ensure that all io-related tests were run on both libnative and libgreen/librustuv. However, now that the librustuv stack is being removed, the macro is no longer needed. See the [runtime removal RFC](https://github.com/rust-lang/rfcs/pull/230) for more context. [breaking-change]
2014-09-08auto merge of #16952 : alexcrichton/rust/windows-large-console-write, r=brsonbors-1/+8
I've found that 64k is still too much and continue to see the errors as reported in #14940. I've locally found that 32k fails, and 24k succeeds, so I've trimmed the size down to 10000 which the included links in the added comment end up recommending. It sounds like the limit can still be hit with many threads in play, but I have yet to reproduce this, so I figure we can wait until that's hit (if it's possible) and then take action.
2014-09-08std: Turn down the stdout chunk sizeAlex Crichton-1/+8
I've found that 64k is still too much and continue to see the errors as reported in #14940. I've locally found that 32k fails, and 24k succeeds, so I've trimmed the size down to 8192 which libuv happens to use as well. It sounds like the limit can still be hit with many threads in play, but I have yet to reproduce this, so I figure we can wait until that's hit (if it's possible) and then take action.
2014-09-03Remove cross-borrowing for traits.Nick Cameron-1/+1
Closes #15349 [breaking-change] Trait objects are no longer implicitly coerced from Box<T> to &T. You must make an explicit coercion using `&*`.
2014-08-13std: Rename various slice traits for consistencyBrian Anderson-1/+1
ImmutableVector -> ImmutableSlice ImmutableEqVector -> ImmutableEqSlice ImmutableOrdVector -> ImmutableOrdSlice MutableVector -> MutableSlice MutableVectorAllocating -> MutableSliceAllocating MutableCloneableVector -> MutableCloneableSlice MutableOrdVector -> MutableOrdSlice These are all in the prelude so most code will not break. [breaking-change]
2014-08-07auto merge of #16220 : tshepang/rust/temp, r=steveklabnikbors-1/+1
2014-08-06Use byte literals in libstdnham-1/+1
2014-08-03doc: make the sentence make more senseTshepang Lekhonkhobe-1/+1
2014-07-13Stabilization for `owned` (now `boxed`) and `cell`Aaron Turon-1/+1
This PR is the outcome of the library stabilization meeting for the `liballoc::owned` and `libcore::cell` modules. Aside from the stability attributes, there are a few breaking changes: * The `owned` modules is now named `boxed`, to better represent its contents. (`box` was unavailable, since it's a keyword.) This will help avoid the misconception that `Box` plays a special role wrt ownership. * The `AnyOwnExt` extension trait is renamed to `BoxAny`, and its `move` method is renamed to `downcast`, in both cases to improve clarity. * The recently-added `AnySendOwnExt` extension trait is removed; it was not being used and is unnecessary. [breaking-change]
2014-07-08std: Rename the `ToStr` trait to `ToString`, and `to_str` to `to_string`.Richo Healey-2/+2
[breaking-change]
2014-06-18Deprecate the bytes!() macro.Simon Sapin-1/+1
Replace its usage with byte string literals, except in `bytes!()` tests. Also add a new snapshot, to be able to use the new b"foo" syntax. The src/etc/2014-06-rewrite-bytes-macros.py script automatically rewrites `bytes!()` invocations into byte string literals. Pass it filenames as arguments to generate a diff that you can inspect, or `--apply` followed by filenames to apply the changes in place. Diffs can be piped into `tip` or `pygmentize -l diff` for coloring.
2014-06-16std: Chunk writing to stdout on windowsAlex Crichton-4/+15
This just takes a similar approach to reading stdin on windows by artificially limiting the size of the buffers going in and out. Closes #14940
2014-06-15Register new snapshotsAlex Crichton-6/+6
2014-06-08Fix spelling errors in comments.Joseph Crail-1/+1
2014-06-06std: Deal with fallout of rtio changesAlex Crichton-64/+36
2014-05-27std: Rename strbuf operations to stringRicho Healey-1/+1
[breaking-change]
2014-05-22auto merge of #14357 : huonw/rust/spelling, r=pnkfelixbors-1/+1
The span on a inner doc-comment would point to the next token, e.g. the span for the `a` line points to the `b` line, and the span of `b` points to the `fn`. ```rust //! a //! b fn bar() {} ```
2014-05-22libstd: Remove `~str` from all `libstd` modules except `fmt` and `str`.Patrick Walton-2/+2
2014-05-22Spelling/doc formatting fixes.Huon Wilson-1/+1
2014-05-20Add .isatty() method to StdReaderKevin Ballard-0/+10
StdWriter has .isatty(). StdReader can trivially vend the same function, and someone asked today on IRC how to call isatty() on stdin.
2014-05-15Updates with core::fmt changesAlex Crichton-3/+3
1. Wherever the `buf` field of a `Formatter` was used, the `Formatter` is used instead. 2. The usage of `write_fmt` is minimized as much as possible, the `write!` macro is preferred wherever possible. 3. Usage of `fmt::write` is minimized, favoring the `write!` macro instead.
2014-05-07core: Add unwrap()/unwrap_err() methods to ResultAlex Crichton-1/+1
These implementations must live in libstd right now because the fmt module has not been migrated yet. This will occur in a later PR. Just to be clear, there are new extension traits, but they are not necessary once the std::fmt module has migrated to libcore, which is a planned migration in the future.
2014-05-06librustc: Remove `~EXPR`, `~TYPE`, and `~PAT` from the language, exceptPatrick Walton-10/+10
for `~str`/`~[]`. Note that `~self` still remains, since I forgot to add support for `Box<self>` before the snapshot. How to update your code: * Instead of `~EXPR`, you should write `box EXPR`. * Instead of `~TYPE`, you should write `Box<Type>`. * Instead of `~PATTERN`, you should write `box PATTERN`. [breaking-change]
2014-05-02Replace most ~exprs with 'box'. #11779Brian Anderson-3/+3
2014-04-22Fixed Win64 buildVadim Chugunov-14/+2
2014-04-18Replace all ~"" with "".to_owned()Richo Healey-1/+1
2014-04-15std: Impl Deref/DerefMut for a borrowed taskAlex Crichton-4/+2
2014-04-14Use new attribute syntax in python files in src/etc too (#13478)Manish Goregaokar-1/+1
2014-04-08std: User a smaller stdin buffer on windowsAlex Crichton-1/+9
Apparently windows doesn't like reading from stdin with a large buffer size, and it also apparently is ok with a smaller buffer size. This changes the reader returned by stdin() to return an 8k buffered reader for stdin rather than a 64k buffered reader. Apparently libuv has run into this before, taking a peek at their code, with a specific comment in their console code saying that "ReadConsole can't handle big buffers", which I presume is related to invoking ReadFile as if it were a file descriptor. Closes #13304
2014-03-31std: Switch field privacy as necessaryAlex Crichton-2/+2
2014-03-27Fix fallout of removing default boundsAlex Crichton-9/+12
This is all purely fallout of getting the previous commit to compile.
2014-03-20auto merge of #12980 : cmr/rust/overhaul-stdio, r=thestingerbors-1/+7
this comes from a discussion on IRC where the split between stdin and stdout seemed unnatural, and the fact that reading on stdin won't flush stdout, which is unlike every other language (including C's stdio).
2014-03-20rename std::vec -> std::sliceDaniel Micay-1/+1
Closes #12702
2014-03-19std: io: flush stdout on stdin read from ttyCorey Richardson-1/+7
2014-03-13std: Rename Chan/Port types and constructorAlex Crichton-6/+6
* Chan<T> => Sender<T> * Port<T> => Receiver<T> * Chan::new() => channel() * constructor returns (Sender, Receiver) instead of (Receiver, Sender) * local variables named `port` renamed to `rx` * local variables named `chan` renamed to `tx` Closes #11765
2014-03-01std: Switch stdout/stderr to buffered by defaultAlex Crichton-5/+29
Similarly to #12422 which made stdin buffered by default, this commit makes the output streams also buffered by default. Now that buffered writers will flush their contents when they are dropped, I don't believe that there's no reason why the output shouldn't be buffered by default, which is what you want in 90% of cases. As with stdin, there are new stdout_raw() and stderr_raw() functions to get unbuffered streams to stdout/stderr.
2014-02-23Closes #12386. Removed 'pub mod' doc-comments in std::io's mod.rs file. ↵zslayton-5/+5
Added summary doc-comments to test.rs, util.rs and stdio.rs.
2014-02-20Return a buffered stdin by default.Alex Crichton-3/+16
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-11Move replace and swap to std::mem. Get rid of std::utilEdward Wang-4/+4
Also move Void to std::any, move drop to std::mem and reexport in prelude.
2014-02-03std: Fixing all documentationAlex Crichton-7/+8
* 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-2/+2
2014-02-03std: Remove io::io_errorAlex Crichton-47/+29
* 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-29Removing do keyword from libstd and librustcScott Lawrence-4/+4
2014-01-17Tweak the interface of std::ioAlex Crichton-2/+1
* 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-09Remove eof() from io::ReaderAlex Crichton-2/+0
2014-01-07std: Fill in all missing importsAlex Crichton-0/+3
Fallout from the previous commits
2014-01-07auto merge of #11353 : alexcrichton/rust/improve-logging, r=brsonbors-27/+105
This will allow capturing of common things like logging messages, stdout prints (using stdio println), and failure messages (printed to stderr). Any new prints added to libstd should be funneled through these task handles to allow capture as well. Additionally, this commit redirects logging back through a `Logger` trait so the log level can be usefully consumed by an arbitrary logger. This commit also introduces methods to set the task-local stdout handles: * std::io::stdio::set_stdout * std::io::stdio::set_stderr * std::io::logging::set_logger These methods all return the previous logger just in case it needs to be used for inspection. I plan on using this infrastructure for extra::test soon, but we don't quite have the primitives that I'd like to use for it, so it doesn't migrate extra::test at this time. Closes #6369
2014-01-06Support arbitrary stdout/stderr/logger handlesAlex Crichton-27/+105
This will allow capturing of common things like logging messages, stdout prints (using stdio println), and failure messages (printed to stderr). Any new prints added to libstd should be funneled through these task handles to allow capture as well. Additionally, this commit redirects logging back through a `Logger` trait so the log level can be usefully consumed by an arbitrary logger. This commit also introduces methods to set the task-local stdout handles: * std::io::stdio::set_stdout * std::io::stdio::set_stderr * std::io::logging::set_logger These methods all return the previous logger just in case it needs to be used for inspection. I plan on using this infrastructure for extra::test soon, but we don't quite have the primitives that I'd like to use for it, so it doesn't migrate extra::test at this time. Closes #6369