]> git.lizzy.rs Git - rust.git/commitdiff
Fix Iterator::fuse example
authorSteven Fackler <sfackler@gmail.com>
Fri, 26 Sep 2014 06:02:28 +0000 (23:02 -0700)
committerSteven Fackler <sfackler@gmail.com>
Fri, 26 Sep 2014 06:06:34 +0000 (23:06 -0700)
The for loop would *always* exaust the iterator previously, which seems
like behavior that was not intended. It's still kind of a weird
function.

src/libcore/iter.rs

index f78c8c2aa0ed27ad8b77396a4a4bfc5e4da0aaeb..9799e9d398055ab23667d5d589572ac104f24ac1 100644 (file)
@@ -366,7 +366,7 @@ fn flat_map<'r, B, U: Iterator<B>>(self, f: |A|: 'r -> U)
     ///     let mut sum = 0;
     ///     for x in it {
     ///         if x > 5 {
-    ///             continue;
+    ///             break;
     ///         }
     ///         sum += x;
     ///     }
@@ -377,6 +377,8 @@ fn flat_map<'r, B, U: Iterator<B>>(self, f: |A|: 'r -> U)
     ///     sum
     /// }
     /// let x = vec![1i,2,3,7,8,9];
+    /// assert_eq!(process(x.into_iter()), 6);
+    /// let x = vec![1i,2,3];
     /// assert_eq!(process(x.into_iter()), 1006);
     /// ```
     #[inline]