iterator: simplify the take
implementation
This commit is contained in:
parent
6972eb4cd7
commit
b3a317c368
@ -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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user