2012-04-11 23:45:18 -05:00
|
|
|
// This makes use of a clever hack that brson came up with to
|
|
|
|
// workaround our lack of traits and lack of macros. See core.{rc,rs} for
|
|
|
|
// how this file is used.
|
|
|
|
|
2012-10-03 16:52:09 -05:00
|
|
|
#[forbid(deprecated_mode)];
|
|
|
|
#[forbid(deprecated_pattern)];
|
2012-09-25 19:39:22 -05:00
|
|
|
|
2012-09-04 13:12:17 -05:00
|
|
|
use cmp::{Eq, Ord};
|
|
|
|
use inst::{IMPL_T, EACH, SIZE_HINT};
|
2012-04-11 23:45:18 -05:00
|
|
|
|
2012-08-14 18:54:13 -05:00
|
|
|
impl<A> IMPL_T<A>: iter::BaseIter<A> {
|
2012-09-25 19:39:22 -05:00
|
|
|
pure fn each(blk: fn(v: &A) -> bool) { EACH(&self, blk) }
|
|
|
|
pure fn size_hint() -> Option<uint> { SIZE_HINT(&self) }
|
2012-07-11 17:00:40 -05:00
|
|
|
}
|
|
|
|
|
2012-08-14 18:54:13 -05:00
|
|
|
impl<A> IMPL_T<A>: iter::ExtendedIter<A> {
|
2012-09-25 19:39:22 -05:00
|
|
|
pure fn eachi(blk: fn(uint, v: &A) -> bool) { iter::eachi(&self, blk) }
|
2012-09-28 19:04:39 -05:00
|
|
|
pure fn all(blk: fn(&A) -> bool) -> bool { iter::all(&self, blk) }
|
|
|
|
pure fn any(blk: fn(&A) -> bool) -> bool { iter::any(&self, blk) }
|
2012-10-02 13:37:37 -05:00
|
|
|
pure fn foldl<B>(b0: B, blk: fn(&B, &A) -> B) -> B {
|
2012-09-28 18:37:14 -05:00
|
|
|
iter::foldl(&self, move b0, blk)
|
2012-04-11 23:45:18 -05:00
|
|
|
}
|
2012-09-28 23:51:14 -05:00
|
|
|
pure fn position(f: fn(&A) -> bool) -> Option<uint> {
|
|
|
|
iter::position(&self, f)
|
2012-09-13 11:13:03 -05:00
|
|
|
}
|
2012-08-27 18:26:35 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
impl<A: Eq> IMPL_T<A>: iter::EqIter<A> {
|
2012-09-28 23:51:14 -05:00
|
|
|
pure fn contains(x: &A) -> bool { iter::contains(&self, x) }
|
2012-09-28 18:37:14 -05:00
|
|
|
pure fn count(x: &A) -> uint { iter::count(&self, x) }
|
2012-04-11 23:45:18 -05:00
|
|
|
}
|
|
|
|
|
2012-09-07 16:52:28 -05:00
|
|
|
impl<A: Copy> IMPL_T<A>: iter::CopyableIter<A> {
|
2012-10-02 13:37:37 -05:00
|
|
|
pure fn filter_to_vec(pred: fn(a: A) -> bool) -> ~[A] {
|
2012-09-28 19:04:39 -05:00
|
|
|
iter::filter_to_vec(&self, pred)
|
2012-04-11 23:45:18 -05:00
|
|
|
}
|
2012-10-02 13:37:37 -05:00
|
|
|
pure fn map_to_vec<B>(op: fn(v: A) -> B) -> ~[B] {
|
2012-09-28 19:04:39 -05:00
|
|
|
iter::map_to_vec(&self, op)
|
2012-08-23 12:22:14 -05:00
|
|
|
}
|
2012-09-28 18:37:14 -05:00
|
|
|
pure fn to_vec() -> ~[A] { iter::to_vec(&self) }
|
2012-04-11 23:45:18 -05:00
|
|
|
|
2012-10-02 13:37:37 -05:00
|
|
|
pure fn flat_map_to_vec<B:Copy,IB:BaseIter<B>>(op: fn(a: A) -> IB)
|
2012-09-28 19:04:39 -05:00
|
|
|
-> ~[B] {
|
|
|
|
iter::flat_map_to_vec(&self, op)
|
|
|
|
}
|
2012-04-11 23:45:18 -05:00
|
|
|
|
2012-10-02 13:37:37 -05:00
|
|
|
pure fn find(p: fn(a: A) -> bool) -> Option<A> { iter::find(&self, p) }
|
2012-08-27 18:26:35 -05:00
|
|
|
}
|
|
|
|
|
2012-09-07 16:52:28 -05:00
|
|
|
impl<A: Copy Ord> IMPL_T<A>: iter::CopyableOrderedIter<A> {
|
2012-09-28 18:37:14 -05:00
|
|
|
pure fn min() -> A { iter::min(&self) }
|
|
|
|
pure fn max() -> A { iter::max(&self) }
|
2012-04-11 23:45:18 -05:00
|
|
|
}
|
2012-08-27 18:26:35 -05:00
|
|
|
|