fix Iter::rposition for new arith-overflow checking.
This commit is contained in:
parent
6d6038a194
commit
eadc8a7b45
1 changed files with 3 additions and 2 deletions
|
@ -728,10 +728,11 @@ pub trait IteratorExt: Iterator + Sized {
|
|||
P: FnMut(Self::Item) -> bool,
|
||||
Self: ExactSizeIterator + DoubleEndedIterator
|
||||
{
|
||||
let mut i = self.len() - 1;
|
||||
let mut i = self.len();
|
||||
|
||||
while let Some(v) = self.next_back() {
|
||||
if predicate(v) {
|
||||
return Some(i);
|
||||
return Some(i - 1);
|
||||
}
|
||||
i -= 1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue