Skip to content

Commit 109055c

Browse files
committed
make iter::position() not require Eq
1 parent 7e56612 commit 109055c

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

src/libcore/iter-trait.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ impl<A> IMPL_T<A>: iter::ExtendedIter<A> {
1818
pure fn foldl<B>(+b0: B, blk: fn(B, A) -> B) -> B {
1919
iter::foldl(self, move b0, blk)
2020
}
21+
pure fn position(f: fn(A) -> bool) -> Option<uint> {
22+
iter::position(self, f)
23+
}
2124
}
2225

2326
impl<A: Eq> IMPL_T<A>: iter::EqIter<A> {
2427
pure fn contains(x: A) -> bool { iter::contains(self, x) }
2528
pure fn count(x: A) -> uint { iter::count(self, x) }
26-
pure fn position(f: fn(A) -> bool) -> Option<uint> {
27-
iter::position(self, f)
28-
}
2929
}
3030

3131
impl<A: Copy> IMPL_T<A>: iter::CopyableIter<A> {

src/libcore/iter.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ trait ExtendedIter<A> {
1313
pure fn all(blk: fn(A) -> bool) -> bool;
1414
pure fn any(blk: fn(A) -> bool) -> bool;
1515
pure fn foldl<B>(+b0: B, blk: fn(B, A) -> B) -> B;
16+
pure fn position(f: fn(A) -> bool) -> Option<uint>;
1617
}
1718

1819
trait EqIter<A:Eq> {
1920
pure fn contains(x: A) -> bool;
2021
pure fn count(x: A) -> uint;
21-
pure fn position(f: fn(A) -> bool) -> Option<uint>;
2222
}
2323

2424
trait Times {
@@ -142,7 +142,8 @@ pure fn count<A:Eq,IA:BaseIter<A>>(self: IA, x: A) -> uint {
142142
}
143143

144144
pure fn position<A,IA:BaseIter<A>>(self: IA, f: fn(A) -> bool)
145-
-> Option<uint> {
145+
-> Option<uint>
146+
{
146147
let mut i = 0;
147148
for self.each |a| {
148149
if f(a) { return Some(i); }

src/libcore/vec.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2019,14 +2019,14 @@ impl<A> &[A]: iter::ExtendedIter<A> {
20192019
pure fn foldl<B>(+b0: B, blk: fn(B, A) -> B) -> B {
20202020
iter::foldl(self, move b0, blk)
20212021
}
2022+
pure fn position(f: fn(A) -> bool) -> Option<uint> {
2023+
iter::position(self, f)
2024+
}
20222025
}
20232026

20242027
impl<A: Eq> &[A]: iter::EqIter<A> {
20252028
pure fn contains(x: A) -> bool { iter::contains(self, x) }
20262029
pure fn count(x: A) -> uint { iter::count(self, x) }
2027-
pure fn position(f: fn(A) -> bool) -> Option<uint> {
2028-
iter::position(self, f)
2029-
}
20302030
}
20312031

20322032
impl<A: Copy> &[A]: iter::CopyableIter<A> {

0 commit comments

Comments
 (0)