iterator: simplify the take implementation
This commit is contained in:
parent
6972eb4cd7
commit
b3a317c368
1 changed files with 1 additions and 2 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue