Skip to content

Commit

Permalink
Implement DoubleEndedIterator for Drain.
Browse files Browse the repository at this point in the history
  • Loading branch information
bodil committed Apr 13, 2019
1 parent 785b590 commit 81edef2
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/sized_chunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 +931,20 @@ where
}
}

impl<'a, A, N> DoubleEndedIterator for Drain<'a, A, N>
where
A: 'a,
N: ChunkLength<A> + 'a,
{
fn next_back(&mut self) -> Option<Self::Item> {
if self.chunk.is_empty() {
None
} else {
Some(self.chunk.pop_back())
}
}
}

impl<'a, A, N> ExactSizeIterator for Drain<'a, A, N>
where
A: 'a,
Expand Down

0 comments on commit 81edef2

Please sign in to comment.