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.
This commit is contained in:
parent
19a38de68a
commit
0e597d4c47
2 changed files with 6 additions and 7 deletions
|
@ -66,13 +66,6 @@ impl<I> Iterator for Rev<I> where I: DoubleEndedIterator {
|
|||
{
|
||||
self.iter.rfind(predicate)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn rposition<P>(&mut self, predicate: P) -> Option<usize> where
|
||||
P: FnMut(Self::Item) -> bool
|
||||
{
|
||||
self.iter.position(predicate)
|
||||
}
|
||||
}
|
||||
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
|
|
|
@ -1688,6 +1688,12 @@ fn test_rposition() {
|
|||
assert!(v.iter().rposition(g).is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_rev_rposition() {
|
||||
let v = [0, 0, 1, 1];
|
||||
assert_eq!(v.iter().rev().rposition(|&x| x == 1), Some(1));
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn test_rposition_panic() {
|
||||
|
|
Loading…
Add table
Reference in a new issue