Skip to content

Commit 0e597d4

Browse files
committed
Rev::rposition counts from the wrong end
Because of a compiler bug that adding `Self: ExactSizeIterator` makes the compiler forget `Self::Item` is `<I as Iterator>::Item`, we remove this specialization for now.
1 parent 19a38de commit 0e597d4

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

src/libcore/iter/adapters/mod.rs

-7
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,6 @@ impl<I> Iterator for Rev<I> where I: DoubleEndedIterator {
6666
{
6767
self.iter.rfind(predicate)
6868
}
69-
70-
#[inline]
71-
fn rposition<P>(&mut self, predicate: P) -> Option<usize> where
72-
P: FnMut(Self::Item) -> bool
73-
{
74-
self.iter.position(predicate)
75-
}
7669
}
7770

7871
#[stable(feature = "rust1", since = "1.0.0")]

src/libcore/tests/iter.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1688,6 +1688,12 @@ fn test_rposition() {
16881688
assert!(v.iter().rposition(g).is_none());
16891689
}
16901690

1691+
#[test]
1692+
fn test_rev_rposition() {
1693+
let v = [0, 0, 1, 1];
1694+
assert_eq!(v.iter().rev().rposition(|&x| x == 1), Some(1));
1695+
}
1696+
16911697
#[test]
16921698
#[should_panic]
16931699
fn test_rposition_panic() {

0 commit comments

Comments
 (0)