summary refs log tree commit diff
path: root/src/libstd/io/extensions.rs
AgeCommit message (Collapse)AuthorLines
2014-06-24librustc: Remove the fallback to `int` from typechecking.Niko Matsakis-2/+2
This breaks a fair amount of code. The typical patterns are: * `for _ in range(0, 10)`: change to `for _ in range(0u, 10)`; * `println!("{}", 3)`: change to `println!("{}", 3i)`; * `[1, 2, 3].len()`: change to `[1i, 2, 3].len()`. RFC #30. Closes #6023. [breaking-change]
2014-06-11rustc: Remove ~[T] from the languageAlex Crichton-2/+2
The following features have been removed * box [a, b, c] * ~[a, b, c] * box [a, ..N] * ~[a, ..N] * ~[T] (as a type) * deprecated_owned_vector lint All users of ~[T] should move to using Vec<T> instead.
2014-06-08core: Rename `container` mod to `collections`. Closes #12543Brian Anderson-2/+2
Also renames the `Container` trait to `Collection`. [breaking-change]
2014-05-13io: Add .read_at_least() to ReaderKevin Ballard-18/+18
Reader.read_at_least() ensures that at least a given number of bytes have been read. The most common use-case for this is ensuring at least 1 byte has been read. If the reader returns 0 enough times in a row, a new error kind NoProgress will be returned instead of looping infinitely. This change is necessary in order to properly support Readers that repeatedly return 0, either because they're broken, or because they're attempting to do a non-blocking read on some resource that never becomes available. Also add .push() and .push_at_least() methods. push() is like read() but the results are appended to the passed Vec. Remove Reader.fill() and Reader.push_exact() as they end up being thin wrappers around read_at_least() and push_at_least(). [breaking-change]
2014-05-11core: Remove the cast moduleAlex Crichton-2/+2
This commit revisits the `cast` module in libcore and libstd, and scrutinizes all functions inside of it. The result was to remove the `cast` module entirely, folding all functionality into the `mem` module. Specifically, this is the fate of each function in the `cast` module. * transmute - This function was moved to `mem`, but it is now marked as #[unstable]. This is due to planned changes to the `transmute` function and how it can be invoked (see the #[unstable] comment). For more information, see RFC 5 and #12898 * transmute_copy - This function was moved to `mem`, with clarification that is is not an error to invoke it with T/U that are different sizes, but rather that it is strongly discouraged. This function is now #[stable] * forget - This function was moved to `mem` and marked #[stable] * bump_box_refcount - This function was removed due to the deprecation of managed boxes as well as its questionable utility. * transmute_mut - This function was previously deprecated, and removed as part of this commit. * transmute_mut_unsafe - This function doesn't serve much of a purpose when it can be achieved with an `as` in safe code, so it was removed. * transmute_lifetime - This function was removed because it is likely a strong indication that code is incorrect in the first place. * transmute_mut_lifetime - This function was removed for the same reasons as `transmute_lifetime` * copy_lifetime - This function was moved to `mem`, but it is marked `#[unstable]` now due to the likelihood of being removed in the future if it is found to not be very useful. * copy_mut_lifetime - This function was also moved to `mem`, but had the same treatment as `copy_lifetime`. * copy_lifetime_vec - This function was removed because it is not used today, and its existence is not necessary with DST (copy_lifetime will suffice). In summary, the cast module was stripped down to these functions, and then the functions were moved to the `mem` module. transmute - #[unstable] transmute_copy - #[stable] forget - #[stable] copy_lifetime - #[unstable] copy_mut_lifetime - #[unstable] [breaking-change]
2014-05-02Replace most ~exprs with 'box'. #11779Brian Anderson-1/+1
2014-04-18std: Make ~[T] no longer a growable vectorAlex Crichton-5/+6
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-15Use the unsigned integer types for bitwise intrinsics.Huon Wilson-7/+7
Exposing ctpop, ctlz, cttz and bswap as taking signed i8/i16/... is just exposing the internal LLVM names pointlessly (LLVM doesn't have "signed integers" or "unsigned integers", it just has sized integer types with (un)signed *operations*). These operations are semantically working with raw bytes, which the unsigned types model better.
2014-04-11libtest: rename `BenchHarness` to `Bencher`Liigo Zhuang-8/+8
Closes #12640
2014-04-10std,serialize: remove some internal uses of ~[].Huon Wilson-5/+5
These are all private uses of ~[], so can easily & non-controversially be replaced with Vec.
2014-04-06De-~[] Mem{Reader,Writer}Steven Fackler-5/+5
2014-04-06De-~[] Reader and WriterSteven Fackler-12/+12
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-1/+1
2014-03-28Convert most code to new inner attribute syntax.Brian Anderson-1/+1
Closes #2569
2014-03-25libstd: Document the following modules:Patrick Walton-5/+44
* native::io * std::char * std::fmt * std::fmt::parse * std::io * std::io::extensions * std::io::net::ip * std::io::net::udp * std::io::net::unix * std::io::pipe * std::num * std::num::f32 * std::num::f64 * std::num::strconv * std::os
2014-03-20std: Rename {push,read}_bytes to {push,read}_exactAlex Crichton-11/+11
These methods can be mistaken for general "read some bytes" utilities when they're actually only meant for reading an exact number of bytes. By renaming them it's much clearer about what they're doing without having to read the documentation. Closes #12892
2014-03-20rename std::vec -> std::sliceDaniel Micay-4/+4
Closes #12702
2014-03-12Update io iterators to produce IoResultsPalmer Cox-12/+17
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-02-28std: Improve some I/O documentationAlex Crichton-0/+2
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-20move extra::test to libtestLiigo Zhuang-1/+2
2014-02-13remove duplicate function from std::ptr (is_null, is_not_null, offset, ↵JeremyLetang-3/+4
mut_offset)
2014-02-09std: Move byteswap functions to memBrian Anderson-3/+3
2014-02-03std: Fix tests with io_error usageAlex Crichton-84/+48
2014-02-03std: Remove io::io_errorAlex Crichton-1/+1
* 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-02-01Optimize u64_to_{le,be}_bytesBjörn Steinbrink-28/+14
LLVM fails to properly optimize the shifts used to convert the source value to the right endianess. The resulting assembly copies the value to the stack one byte at a time even when there's no conversion required (e.g. u64_to_le_bytes on a little endian machine). Instead of doing the conversion ourselves using shifts, we can use the existing intrinsics to perform the endianess conversion and then transmute the value to get a fixed vector of its bytes. Before: test be_i8 ... bench: 21442 ns/iter (+/- 70) test be_i16 ... bench: 21447 ns/iter (+/- 45) test be_i32 ... bench: 23832 ns/iter (+/- 63) test be_i64 ... bench: 26887 ns/iter (+/- 267) test le_i8 ... bench: 21442 ns/iter (+/- 56) test le_i16 ... bench: 21448 ns/iter (+/- 36) test le_i32 ... bench: 23825 ns/iter (+/- 153) test le_i64 ... bench: 26271 ns/iter (+/- 138) After: test be_i8 ... bench: 21438 ns/iter (+/- 10) test be_i16 ... bench: 21441 ns/iter (+/- 15) test be_i32 ... bench: 19057 ns/iter (+/- 6) test be_i64 ... bench: 21439 ns/iter (+/- 34) test le_i8 ... bench: 21438 ns/iter (+/- 19) test le_i16 ... bench: 21439 ns/iter (+/- 8) test le_i32 ... bench: 21439 ns/iter (+/- 19) test le_i64 ... bench: 21438 ns/iter (+/- 22)
2014-01-30Prefix _ to unused variables.OGINO Masanori-1/+1
Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
2014-01-26Removed all instances of XXX in preparation for relaxing of FIXME ruleSalem Talha-2/+2
2014-01-25Uppercase numeric constantsChris Wong-4/+4
The following are renamed: * `min_value` => `MIN` * `max_value` => `MAX` * `bits` => `BITS` * `bytes` => `BYTES` Fixes #10010.
2014-01-21Remove unnecessary parentheses.Huon Wilson-1/+1
2014-01-18Rename iterators for consistencyPalmer Cox-6/+6
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-1/+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) cc #11119
2014-01-17Tweak the interface of std::ioAlex Crichton-1/+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-12Removed remnants of `@mut` and `~mut` from comments and the type system.Eduard Burtescu-3/+3
2014-01-10std::io: Optimize u64_from_be_bytes()Carl-Anton Ingmarsson-11/+19
Instead of reading a byte at a time in a loop we copy the relevant bytes into a temporary vector of size eight. We can then read the value from the temporary vector using a single u64 read. LLVM seems to be able to optimize this almost scarily good.
2014-01-10std::io: Add tests and benchmarks for u64_from_be_bytes()Carl-Anton Ingmarsson-0/+82
2014-01-09Remove eof() from io::ReaderAlex Crichton-18/+0
2014-01-08Remove the io::Decorator traitAlex Crichton-6/+5
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-07stdtest: Fix all leaked trait importsAlex Crichton-4/+5
2014-01-07std: Fill in all missing importsAlex Crichton-0/+1
Fallout from the previous commits
2014-01-03libsyntax: Fix tests.Patrick Walton-0/+1
2014-01-03libstd: Remove a spurious `@mut` from a disabled testPatrick Walton-2/+3
2013-12-11std::io: Add Buffer.lines(), change .bytes() apiklutzy-15/+9
- `Buffer.lines()` returns `LineIterator` which yields line using `.read_line()`. - `Reader.bytes()` now takes `&mut self` instead of `self`. - `Reader.read_until()` swallows `EndOfFile`. This also affects `.read_line()`.
2013-11-26test: Remove non-procedure uses of `do` from compiletest, libstd tests,Patrick Walton-16/+16
compile-fail tests, run-fail tests, and run-pass tests.
2013-11-19libstd: Change all uses of `&fn(A)->B` over to `|A|->B` in libstdPatrick Walton-4/+2
2013-11-11Move std::rt::io to std::ioAlex Crichton-0/+491