diff options
| author | bors <bors@rust-lang.org> | 2013-04-28 19:36:36 -0700 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-04-28 19:36:36 -0700 |
| commit | 7b7a0fc235cd2e0782302cd6fb83634e190b15b7 (patch) | |
| tree | c4d6aedddc64db81f6ada877e9ec585cf981d2d9 /src/libsyntax | |
| parent | 9f03d45c56b37b36912c16bd5b4fb4723fd91cb7 (diff) | |
| parent | 46f91a0fa95cd13f7433a1d72d087283f483a4b8 (diff) | |
| download | rust-7b7a0fc235cd2e0782302cd6fb83634e190b15b7.tar.gz rust-7b7a0fc235cd2e0782302cd6fb83634e190b15b7.zip | |
auto merge of #6056 : thestinger/rust/iter, r=catamorphism
The existing adaptors like `map` in the `iter` module are very flawed because they only work for `BaseIter` implementations. There are many internal iterator implementations in the standard library like the set methods (`difference`, `symmetric_difference`, `intersection`, `union`) and the `range` functions that only share the `for` loop protocol in common. The internal iterator adaptors should be implemented to work on any implementation of that protocol, rather than just a method called `each` taking `&self`. This just moves `iter.rs` to `old_iter.rs` and begins work on documenting and implementing a nicer module.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/opt_vec.rs | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/src/libsyntax/opt_vec.rs b/src/libsyntax/opt_vec.rs index 88d7c39cc83..fd1c5a960d1 100644 --- a/src/libsyntax/opt_vec.rs +++ b/src/libsyntax/opt_vec.rs @@ -16,8 +16,9 @@ * other useful things like `push()` and `len()`. */ -use core::iter; -use core::iter::BaseIter; +use core::prelude::*; +use core::old_iter; +use core::old_iter::BaseIter; #[auto_encode] #[auto_decode] @@ -116,7 +117,7 @@ impl<T:Copy> OptVec<T> { #[inline(always)] fn mapi_to_vec<B>(&self, op: &fn(uint, &T) -> B) -> ~[B] { let mut index = 0; - iter::map_to_vec(self, |a| { + old_iter::map_to_vec(self, |a| { let i = index; index += 1; op(i, a) @@ -154,62 +155,62 @@ impl<A> BaseIter<A> for OptVec<A> { } } -impl<A> iter::ExtendedIter<A> for OptVec<A> { +impl<A> old_iter::ExtendedIter<A> for OptVec<A> { #[inline(always)] fn eachi(&self, blk: &fn(v: uint, v: &A) -> bool) { - iter::eachi(self, blk) + old_iter::eachi(self, blk) } #[inline(always)] fn all(&self, blk: &fn(&A) -> bool) -> bool { - iter::all(self, blk) + old_iter::all(self, blk) } #[inline(always)] fn any(&self, blk: &fn(&A) -> bool) -> bool { - iter::any(self, blk) + old_iter::any(self, blk) } #[inline(always)] fn foldl<B>(&self, b0: B, blk: &fn(&B, &A) -> B) -> B { - iter::foldl(self, b0, blk) + old_iter::foldl(self, b0, blk) } #[inline(always)] fn position(&self, f: &fn(&A) -> bool) -> Option<uint> { - iter::position(self, f) + old_iter::position(self, f) } #[inline(always)] fn map_to_vec<B>(&self, op: &fn(&A) -> B) -> ~[B] { - iter::map_to_vec(self, op) + old_iter::map_to_vec(self, op) } #[inline(always)] fn flat_map_to_vec<B,IB:BaseIter<B>>(&self, op: &fn(&A) -> IB) -> ~[B] { - iter::flat_map_to_vec(self, op) + old_iter::flat_map_to_vec(self, op) } } -impl<A: Eq> iter::EqIter<A> for OptVec<A> { +impl<A: Eq> old_iter::EqIter<A> for OptVec<A> { #[inline(always)] - fn contains(&self, x: &A) -> bool { iter::contains(self, x) } + fn contains(&self, x: &A) -> bool { old_iter::contains(self, x) } #[inline(always)] - fn count(&self, x: &A) -> uint { iter::count(self, x) } + fn count(&self, x: &A) -> uint { old_iter::count(self, x) } } -impl<A: Copy> iter::CopyableIter<A> for OptVec<A> { +impl<A: Copy> old_iter::CopyableIter<A> for OptVec<A> { #[inline(always)] fn filter_to_vec(&self, pred: &fn(&A) -> bool) -> ~[A] { - iter::filter_to_vec(self, pred) + old_iter::filter_to_vec(self, pred) } #[inline(always)] - fn to_vec(&self) -> ~[A] { iter::to_vec(self) } + fn to_vec(&self) -> ~[A] { old_iter::to_vec(self) } #[inline(always)] fn find(&self, f: &fn(&A) -> bool) -> Option<A> { - iter::find(self, f) + old_iter::find(self, f) } } -impl<A: Copy+Ord> iter::CopyableOrderedIter<A> for OptVec<A> { +impl<A: Copy+Ord> old_iter::CopyableOrderedIter<A> for OptVec<A> { #[inline(always)] - fn min(&self) -> A { iter::min(self) } + fn min(&self) -> A { old_iter::min(self) } #[inline(always)] - fn max(&self) -> A { iter::max(self) } + fn max(&self) -> A { old_iter::max(self) } } |
