about summary refs log tree commit diff
path: root/src/libstd/io/buffered.rs
AgeCommit message (Collapse)AuthorLines
2014-10-28Fix example for BufferedReaderSteve Klabnik-4/+3
Fixes #18197
2014-10-20Optimize BufferedReader::read for large buffers.Julian Orth-2/+11
This optimizes `read` for the case in which the number of bytes requested is larger than the internal buffer. Note that the first comparison occurs again right afterwards and should thus be free. The second comparison occurs only in the cold branch.
2014-10-13Clean up rustc warnings.NODA, Kai-3/+3
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-07Use slice syntax instead of slice_to, etc.Nick Cameron-7/+7
2014-10-02Revert "Use slice syntax instead of slice_to, etc."Aaron Turon-7/+7
This reverts commit 40b9f5ded50ac4ce8c9323921ec556ad611af6b7.
2014-10-02Use slice syntax instead of slice_to, etc.Nick Cameron-7/+7
2014-09-21Remove #[allow(deprecated)] from libstdAlex Crichton-5/+5
2014-09-16Fallout from renamingAaron Turon-4/+4
2014-09-16Align with _mut conventionsAaron Turon-1/+1
As per [RFC 52](https://github.com/rust-lang/rfcs/blob/master/active/0052-ownership-variants.md), use `_mut` suffixes to mark mutable variants, and `into_iter` for moving iterators. [breaking-change]
2014-08-28Fallout from stabilizing core::optionAaron Turon-1/+1
2014-08-26Use temp vars for implicit coercion to ^[T]Nick Cameron-24/+38
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-06Use byte literals in libstdnham-7/+7
2014-07-21Add a ton of ignore-lexer-testCorey Richardson-0/+2
2014-06-18Deprecate the bytes!() macro.Simon Sapin-2/+2
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-08core: Rename `container` mod to `collections`. Closes #12543Brian Anderson-1/+1
Also renames the `Container` trait to `Collection`. [breaking-change]
2014-05-30std: Rename {Eq,Ord} to Partial{Eq,Ord}Alex Crichton-1/+1
This is part of the ongoing renaming of the equality traits. See #12517 for more details. All code using Eq/Ord will temporarily need to move to Partial{Eq,Ord} or the Total{Eq,Ord} traits. The Total traits will soon be renamed to {Eq,Ord}. cc #12517 [breaking-change]
2014-05-27std: Rename strbuf operations to stringRicho Healey-6/+6
[breaking-change]
2014-05-22libstd: Remove `~str` from all `libstd` modules except `fmt` and `str`.Patrick Walton-6/+6
2014-05-15Updates with core::fmt changesAlex Crichton-1/+1
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-15std: Modify TempDir to not fail on drop. Closes #12628Brian Anderson-1/+20
After discussion with Alex, we think the proper policy is for dtors to not fail. This is consistent with C++. BufferedWriter already does this, so this patch modifies TempDir to not fail in the dtor, adding a `close` method for handling errors on destruction.
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-04-18Replace all ~"" with "".to_owned()Richo Healey-6/+7
2014-04-18std: Make ~[T] no longer a growable vectorAlex Crichton-3/+3
This removes all resizability support for ~[T] vectors in preparation of DST. The only growable vector remaining is Vec<T>. In summary, the following methods from ~[T] and various functions were removed. Each method/function has an equivalent on the Vec type in std::vec unless otherwise stated. * slice::OwnedCloneableVector * slice::OwnedEqVector * slice::append * slice::append_one * slice::build (no replacement) * slice::bytes::push_bytes * slice::from_elem * slice::from_fn * slice::with_capacity * ~[T].capacity() * ~[T].clear() * ~[T].dedup() * ~[T].extend() * ~[T].grow() * ~[T].grow_fn() * ~[T].grow_set() * ~[T].insert() * ~[T].pop() * ~[T].push() * ~[T].push_all() * ~[T].push_all_move() * ~[T].remove() * ~[T].reserve() * ~[T].reserve_additional() * ~[T].reserve_exect() * ~[T].retain() * ~[T].set_len() * ~[T].shift() * ~[T].shrink_to_fit() * ~[T].swap_remove() * ~[T].truncate() * ~[T].unshift() * ~str.clear() * ~str.set_len() * ~str.truncate() Note that no other API changes were made. Existing apis that took or returned ~[T] continue to do so. [breaking-change]
2014-04-14Use new attribute syntax in python files in src/etc too (#13478)Manish Goregaokar-2/+2
2014-04-11libtest: rename `BenchHarness` to `Bencher`Liigo Zhuang-7/+7
Closes #12640
2014-04-06De-~[] Mem{Reader,Writer}Steven Fackler-4/+4
2014-04-06De-~[] Reader and WriterSteven Fackler-4/+4
There's a little more allocation here and there now since from_utf8_owned can't be used with Vec.
2014-03-31std: Switch field privacy as necessaryAlex Crichton-10/+10
2014-03-24auto merge of #13049 : alexcrichton/rust/io-fill, r=huonwbors-3/+3
This method can be used to fill a byte slice of data entirely, and it's considered an error if any error happens before its entirely filled.
2014-03-22Some cleanup in std::io::bufferedSteven Fackler-15/+24
`Vec` is now used for the internal buffer instead of `~[]`. Some module level documentation somehow ended up attached to `BufferedReader` so I fixed that as well.
2014-03-22std: Add an I/O reader method to fill a bufferAlex Crichton-3/+3
I've found a common use case being to fill a slice (not an owned vector) completely with bytes. It's posible for short reads to happen, and if you're trying to get an exact number of bytes then this helper will be useful.
2014-03-20rename std::vec -> std::sliceDaniel Micay-6/+6
Closes #12702
2014-03-12Update io iterators to produce IoResultsPalmer Cox-5/+5
Most IO related functions return an IoResult so that the caller can handle failure in whatever way is appropriate. However, the `lines`, `bytes`, and `chars` iterators all supress errors. This means that code that needs to handle errors can't use any of these iterators. All three of these iterators were updated to produce IoResults. Fixes #12368
2014-03-06fix typos with with repeated words, just like this sentence.Kang Seonghoon-2/+2
2014-03-01std: Flush when buffered writers are droppedAlex Crichton-14/+25
It's still not entirely clear what should happen if there was an error when flushing, but I'm deferring that decision to #12628. I believe that it's crucial for the usefulness of buffered writers to be able to flush on drop. It's just too easy to forget to flush them in small one-off use cases. cc #12628
2014-02-28std: Change assert_eq!() to use {} instead of {:?}Alex Crichton-21/+21
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-20Mass rename if_ok! to try!Alex Crichton-6/+6
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-20move extra::test to libtestLiigo Zhuang-1/+2
2014-02-14return value/use extra::test::black_box in benchmarkslpy-2/+2
2014-02-13Removed num::OrderableMichael Darakananda-2/+2
2014-02-09std::io: Add `Chars` iterator for Buffer.gifnksm-0/+10
Add `std::io::Chars` iterator and `Buffer#chars()` method
2014-02-03std: Fixing all documentationAlex Crichton-7/+6
* 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-50/+55
2014-02-03std: Remove io::io_errorAlex Crichton-37/+43
* 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-27Demote self to an (almost) regular argument and remove the env param.Eduard Burtescu-1/+1
Fixes #10667 and closes #10259.
2014-01-21[std::vec] Rename .shift_opt() to .shift(), drop the old .shift() behaviorSimon Sapin-1/+1
2014-01-17Tweak the interface of std::ioAlex Crichton-54/+64
* 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-25/+8
2014-01-08Remove the io::Decorator traitAlex Crichton-64/+80
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.