Handle the last chunk correctly
@@ -789,7 +789,7 @@ impl<'data, T: 'data + Send> Producer for ChunksMutProducer<'data, T> {
}
fn split_at(self, index: usize) -> (Self, Self) {
- let elem_index = index * self.chunk_size;
+ let elem_index = cmp::min(index * self.chunk_size, self.slice.len());
let (left, right) = self.slice.split_at_mut(elem_index);
(
ChunksMutProducer {
