Commit Graph

43 Commits

Author SHA1 Message Date
Daniel Micay fd5f8d90c5 iterator: add DoubleEndedIterator concept
This implements the trait for vector iterators, replacing the reverse
iterator types. The methods will stay, for implementing the future
reverse Iterable traits and convenience.

This can also be trivially implemented for circular buffers and other
variants of arrays like strings and `SmallIntMap`/`SmallIntSet`.

The `DoubleEndedIterator` trait will allow for implementing algorithms
like in-place reverse on generic mutable iterators.

The naming (`Range` vs. `Iterator`, `Bidirectional` vs. `DoubleEnded`)
can be bikeshedded in the future.
2013-07-11 01:31:01 -04:00
bors 2a8ae0eb4a auto merge of #7604 : apasel422/rust/peek, r=huonw
This can be useful for inserting debugging code at different steps in an iterator pipeline.
2013-07-08 10:22:57 -07:00
Daniel Micay 641aec7407 remove some method resolve workarounds 2013-07-07 19:51:13 -04:00
Andrew Paseltiner 7bb4ff6267 iterator: Add IteratorUtil::peek_ method 2013-07-07 19:29:37 -04:00
Kevin Ballard 20016b92c8 Implement .size_hint() on the remaining Iterator adaptors
Every iterator adaptor now has an implementation of .size_hint() that
makes sense, except for when the default of (0, None) is correct.
2013-07-05 01:56:48 -07:00
Kevin Ballard dc9b3ff1b3 Change signature of Iterator.size_hint
Remove the Option wrapper around the lower bound. None is semantically
the same as Size(0), so there's no point in having a distinction.
2013-07-05 01:56:48 -07:00
Huon Wilson c0a20d2929 Remove vec::{map, mapi, zip_map} and the methods, except for .map, since this
is very common, and the replacement (.iter().transform().collect()) is very
ugly.
2013-06-30 21:59:44 +10:00
Daniel Micay d820355213 fix code block syntax in two docstrings 2013-06-29 17:33:18 -04:00
Ben Blum ff4ab9e147 'Borrow' stack closures rather than copying them (e.g., "|x|f(x)"), in prep for making them noncopyable. 2013-06-29 04:39:34 -04:00
blake2-ppc b9cf6a33d2 iterator: UnfoldrIterator::new should have function argument last
To match Rust conventions and enable use of `do` etc, make sure the
closure is the last argument to the `new` method.
2013-06-29 01:03:37 -04:00
bors 63afb8ccc8 auto merge of #7430 : huonw/rust/vec-kill, r=thestinger 2013-06-27 15:01:58 -07:00
Huon Wilson 366ca44cc8 std: silence some test warnings. 2013-06-28 01:45:24 +10:00
gifnksm 8edb8f6d39 iterator: Add IteratorUtil::max_by/min_by method 2013-06-27 06:55:22 +09:00
bors 3433851a37 auto merge of #7345 : blake2-ppc/rust/iterator-flat-map, r=thestinger
flat_map_ produces an iterator that maps each element to an iterator,
and yields the elements of the produced iterators.

This is the monadic bind :: M a -> (a -> M b) -> M b  for iterators.

Named just like the vec method, but with a trailing underline until the
method resolution bug is resolved.

We discussed the name chain_map, but I decided to go with flat_map_ for consistency with vec.

Since it.map(f).flatten()  would be the same as it.flat_map(f), we could choose
to just implement a flatten method instead. Either way the possibilities are the same but flat_map is more convenient.
2013-06-26 09:47:16 -07:00
James Miller caa50ce15d Remove stage0 cfgs 2013-06-25 17:08:26 +12:00
blake2-ppc 6291702cf3 iterator: Add IteratorUtil::flat_map_ method
flat_map_ produces an iterator that maps each element to an iterator,
and yields the elements of the produced iterators.

This is the monadic bind :: M a -> (a -> M b) -> M b  for iterators.

Named just like the vec method, but with a trailing underline until the
method resolution bug is resolved.
2013-06-24 12:50:41 +02:00
Daniel Micay 3ab5ec4b7c iterator: implement collect with FromIterator
This makes it take advantage of the size hint for pre-allocation.
2013-06-24 01:35:15 -04:00
Daniel Micay c9342663df iterator: add a FromIterator trait
This is able to take advantage of the lower bound from the size hint.
2013-06-22 15:59:59 -04:00
Daniel Micay 468cbd9d01 iterator: add a size_hint default method
also adds an implementation for the vector iterators
2013-06-22 15:59:59 -04:00
Daniel Micay 883c966d5c vec: replace position with iter().position_ 2013-06-21 03:23:59 -04:00
Daniel Micay 49c74524e2 vec: rm old_iter implementations, except BaseIter
The removed test for issue #2611 is well covered by the `std::iterator`
module itself.

This adds the `count` method to `IteratorUtil` to replace `EqIter`.
2013-06-21 03:20:22 -04:00
Graydon Hoare d904c72af8 replace #[inline(always)] with #[inline]. r=burningtree. 2013-06-18 14:48:48 -07:00
bors fd8aa9afbd auto merge of #7177 : huonw/rust/unfold-fix, r=thestinger 2013-06-16 10:55:02 -07:00
Huon Wilson 53f6a4e9fb std: fix UnfoldrIterator cross-crate. 2013-06-16 18:13:45 +10:00
Daniel Micay 79cd2dbe72 iterator: work around method resolve bug 2013-06-15 18:02:05 -04:00
Daniel Micay 2df66a84cd iterator: add a position adaptor 2013-06-15 17:56:54 -04:00
Daniel Micay eb5ac84c8e iterator: add a find adaptor 2013-06-15 17:53:12 -04:00
Daniel Micay 585f5f7f79 add IteratorUtil to the prelude 2013-06-14 23:15:42 -04:00
bors 78cddc83a4 auto merge of #7073 : influenza/rust/iterator-doc-fixes, r=catamorphism
This commit fixes two typos and an incorrect description.
2013-06-12 12:13:53 -07:00
Ron Dahlgren 37489a67e5 Iterator documentation fixes
Fixes two typos and one incorrect description.
2013-06-11 16:34:03 -07:00
Daniel Micay 004816f4c6 option: remove redundant old_iter impls 2013-06-11 14:06:12 -04:00
Huon Wilson 98ba91f81b remove unused import warnings 2013-06-09 02:22:23 +10:00
Huon Wilson 65c7c58c8f std: remove {all*,any*,count} in favour of iterators 2013-06-09 02:22:23 +10:00
Daniel Micay 07e4d69baa iterator: work around method resolve bug (#5898) 2013-06-07 14:50:06 -04:00
Huon Wilson 5e9f006c5b std: more dummy type parameters on iterators to work around #6967. 2013-06-08 01:10:27 +10:00
Marvin Löbel cac4891154 Fixups 2013-06-06 22:40:35 +02:00
Marvin Löbel 070015468d Removed IteratorUtil::to_vec and iter::to_vec 2013-06-06 22:11:48 +02:00
Marvin Löbel 857d433b9a Added IteratorUtil::collect 2013-06-06 22:11:48 +02:00
Huon Wilson 32228f3d57 std: work-around for take/skip type inference (#6967) 2013-06-06 16:40:12 +10:00
Daniel Farina aef1e10eba Remove unnecessary 'use' forms
Fix a laundry list of warnings involving unused imports that glutted
up compilation output.  There are more, but there seems to be some
false positives (where 'remedy' appears to break the build), but this
particular set of fixes seems safe.
2013-05-30 13:08:18 -07:00
Alex Crichton 007651cd26 Require documentation by default for libstd
Adds documentation for various things that I understand.
Adds #[allow(missing_doc)] for lots of things that I don't understand.
2013-05-30 01:02:55 -05:00
Patrick Walton 206ab89629 librustc: Stop reexporting the standard modules from prelude. 2013-05-29 19:04:53 -07:00
Patrick Walton 0c820d4123 libstd: Rename libcore to libstd and libstd to libextra; update makefiles.
This only changes the directory names; it does not change the "real"
metadata names.
2013-05-22 21:57:05 -07:00