iterator: simplify the take implementation

This commit is contained in:
Daniel Micay 2013-08-05 19:23:29 -04:00
parent 6972eb4cd7
commit b3a317c368

View File

@ -1316,10 +1316,9 @@ pub struct Take<T> {
impl<A, T: Iterator<A>> Iterator<A> for Take<T> {
#[inline]
fn next(&mut self) -> Option<A> {
let next = self.iter.next();
if self.n != 0 {
self.n -= 1;
next
self.iter.next()
} else {
None
}