make iter::position() not require Eq
This commit is contained in:
parent
7e5661214a
commit
109055c7d3
|
@ -18,14 +18,14 @@ impl<A> IMPL_T<A>: iter::ExtendedIter<A> {
|
|||
pure fn foldl<B>(+b0: B, blk: fn(B, A) -> B) -> B {
|
||||
iter::foldl(self, move b0, blk)
|
||||
}
|
||||
pure fn position(f: fn(A) -> bool) -> Option<uint> {
|
||||
iter::position(self, f)
|
||||
}
|
||||
}
|
||||
|
||||
impl<A: Eq> IMPL_T<A>: iter::EqIter<A> {
|
||||
pure fn contains(x: A) -> bool { iter::contains(self, x) }
|
||||
pure fn count(x: A) -> uint { iter::count(self, x) }
|
||||
pure fn position(f: fn(A) -> bool) -> Option<uint> {
|
||||
iter::position(self, f)
|
||||
}
|
||||
}
|
||||
|
||||
impl<A: Copy> IMPL_T<A>: iter::CopyableIter<A> {
|
||||
|
|
|
@ -13,12 +13,12 @@ trait ExtendedIter<A> {
|
|||
pure fn all(blk: fn(A) -> bool) -> bool;
|
||||
pure fn any(blk: fn(A) -> bool) -> bool;
|
||||
pure fn foldl<B>(+b0: B, blk: fn(B, A) -> B) -> B;
|
||||
pure fn position(f: fn(A) -> bool) -> Option<uint>;
|
||||
}
|
||||
|
||||
trait EqIter<A:Eq> {
|
||||
pure fn contains(x: A) -> bool;
|
||||
pure fn count(x: A) -> uint;
|
||||
pure fn position(f: fn(A) -> bool) -> Option<uint>;
|
||||
}
|
||||
|
||||
trait Times {
|
||||
|
@ -142,7 +142,8 @@ pure fn count<A:Eq,IA:BaseIter<A>>(self: IA, x: A) -> uint {
|
|||
}
|
||||
|
||||
pure fn position<A,IA:BaseIter<A>>(self: IA, f: fn(A) -> bool)
|
||||
-> Option<uint> {
|
||||
-> Option<uint>
|
||||
{
|
||||
let mut i = 0;
|
||||
for self.each |a| {
|
||||
if f(a) { return Some(i); }
|
||||
|
|
|
@ -2019,14 +2019,14 @@ impl<A> &[A]: iter::ExtendedIter<A> {
|
|||
pure fn foldl<B>(+b0: B, blk: fn(B, A) -> B) -> B {
|
||||
iter::foldl(self, move b0, blk)
|
||||
}
|
||||
pure fn position(f: fn(A) -> bool) -> Option<uint> {
|
||||
iter::position(self, f)
|
||||
}
|
||||
}
|
||||
|
||||
impl<A: Eq> &[A]: iter::EqIter<A> {
|
||||
pure fn contains(x: A) -> bool { iter::contains(self, x) }
|
||||
pure fn count(x: A) -> uint { iter::count(self, x) }
|
||||
pure fn position(f: fn(A) -> bool) -> Option<uint> {
|
||||
iter::position(self, f)
|
||||
}
|
||||
}
|
||||
|
||||
impl<A: Copy> &[A]: iter::CopyableIter<A> {
|
||||
|
|
Loading…
Reference in New Issue