Skip to content

Commit

Permalink
Auto merge of rust-lang#25698 - mdinger:flat_map, r=steveklabnik
Browse files Browse the repository at this point in the history
I'm not sure why `core` is on but it's blocking the playpen. Doesn't seem to be needed but I'm not sure. It's not on the playpen template and playpen works on release and nightly.

Seems easier to understand without `take()`.
  • Loading branch information
bors committed May 25, 2015
2 parents 6770253 + 5b443b2 commit 1d00028
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions src/libcore/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -452,20 +452,19 @@ pub trait Iterator {
Scan{iter: self, f: f, state: initial_state}
}

/// Creates an iterator that maps each element to an iterator,
/// and yields the elements of the produced iterators.
/// Takes a function that maps each element to a new iterator and yields
/// all the elements of the produced iterators.
///
/// This is useful for unraveling nested structures.
///
/// # Examples
///
/// ```
/// # #![feature(core)]
/// let xs = [2, 3];
/// let ys = [0, 1, 0, 1, 2];
/// let it = xs.iter().flat_map(|&x| (0..).take(x));
/// // Check that `it` has the same elements as `ys`
/// for (i, x) in it.enumerate() {
/// assert_eq!(x, ys[i]);
/// }
/// let words = ["alpha", "beta", "gamma"];
/// let merged: String = words.iter()
/// .flat_map(|s| s.chars())
/// .collect();
/// assert_eq!(merged, "alphabetagamma");
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down

0 comments on commit 1d00028

Please sign in to comment.