core::iter
: fix bug uncovered by arith-overflow.
(The bug was in `impl RandomAccessIterator for Rev`; it may or may not have been innocuous, depending on what guarantees one has about the behavior of `idx` for the underlying iterator.)
This commit is contained in:
parent
6189e99c86
commit
f0404c39f2
1 changed files with 5 additions and 1 deletions
|
@ -1130,7 +1130,11 @@ impl<I> RandomAccessIterator for Rev<I> where I: DoubleEndedIterator + RandomAcc
|
|||
#[inline]
|
||||
fn idx(&mut self, index: usize) -> Option<<I as Iterator>::Item> {
|
||||
let amt = self.indexable();
|
||||
self.iter.idx(amt - index - 1)
|
||||
if amt > index {
|
||||
self.iter.idx(amt - index - 1)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue