]> git.lizzy.rs Git - rust.git/commitdiff
iterator: simplify the `take` implementation
authorDaniel Micay <danielmicay@gmail.com>
Mon, 5 Aug 2013 23:23:29 +0000 (19:23 -0400)
committerDaniel Micay <danielmicay@gmail.com>
Tue, 6 Aug 2013 22:09:20 +0000 (18:09 -0400)
src/libstd/iterator.rs

index 56a0dca56679ccf3a34d89038944614d0c497263..4803e2e004e75c2dc811ab4eff939049afd44bca 100644 (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
         }