mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-29 20:46:07 +03:00
std: Fix bug in ChunkIter::idx
ChunkIter .idx() didn't handle overflow correctly, even though it tried.
This commit is contained in:
+4
-1
@@ -547,7 +547,10 @@ fn indexable(&self) -> uint {
|
||||
fn idx(&self, index: uint) -> Option<&'self [T]> {
|
||||
if index < self.indexable() {
|
||||
let lo = index * self.size;
|
||||
Some(self.v.slice(lo, cmp::min(lo, self.v.len() - self.size) + self.size))
|
||||
let mut hi = lo + self.size;
|
||||
if hi < lo || hi > self.v.len() { hi = self.v.len(); }
|
||||
|
||||
Some(self.v.slice(lo, hi))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user