Skip to content

Commit 1601949

Browse files
committed
Simplify flat_map example
1 parent c3d60ab commit 1601949

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

src/libcore/iter.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -452,20 +452,17 @@ pub trait Iterator {
452452
Scan{iter: self, f: f, state: initial_state}
453453
}
454454

455-
/// Creates an iterator that maps each element to an iterator,
456-
/// and yields the elements of the produced iterators.
455+
/// Creates an iterator that maps an iterator returning function to
456+
/// each element. Yields the elements of the produced iterators.
457457
///
458458
/// # Examples
459459
///
460460
/// ```
461-
/// # #![feature(core)]
462-
/// let xs = [2, 3];
463-
/// let ys = [0, 1, 0, 1, 2];
464-
/// let it = xs.iter().flat_map(|&x| (0..).take(x));
465-
/// // Check that `it` has the same elements as `ys`
466-
/// for (i, x) in it.enumerate() {
467-
/// assert_eq!(x, ys[i]);
468-
/// }
461+
/// let words = ["alpha", "beta", "gamma"];
462+
/// let merge: String = words.iter()
463+
/// .flat_map(|s| s.chars())
464+
/// .collect();
465+
/// assert_eq!(merge, "alphabetagamma");
469466
/// ```
470467
#[inline]
471468
#[stable(feature = "rust1", since = "1.0.0")]

0 commit comments

Comments
 (0)