Skip to content

Commit eadc8a7

Browse files
committed
fix Iter::rposition for new arith-overflow checking.
1 parent 6d6038a commit eadc8a7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/libcore/iter.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -728,10 +728,11 @@ pub trait IteratorExt: Iterator + Sized {
728728
P: FnMut(Self::Item) -> bool,
729729
Self: ExactSizeIterator + DoubleEndedIterator
730730
{
731-
let mut i = self.len() - 1;
731+
let mut i = self.len();
732+
732733
while let Some(v) = self.next_back() {
733734
if predicate(v) {
734-
return Some(i);
735+
return Some(i - 1);
735736
}
736737
i -= 1;
737738
}

0 commit comments

Comments
 (0)