]> git.lizzy.rs Git - rust.git/commit
Rollup merge of #48115 - Centril:feature/iterator_flatten, r=alexcrichton
authorkennytm <kennytm@gmail.com>
Sun, 25 Feb 2018 07:54:41 +0000 (15:54 +0800)
committerGitHub <noreply@github.com>
Sun, 25 Feb 2018 07:54:41 +0000 (15:54 +0800)
commit562626ac3f51d87b87039ba7f73bc251bea6efdf
treebc6e4474ca7b46f1a128fecd7d5ba9e61cf8631c
parent725856d67fafcb19901dfa033d52f38d1994dc17
parent819d57abc94d162e0d6f58fcbed757849f8305b4
Rollup merge of #48115 - Centril:feature/iterator_flatten, r=alexcrichton

Add Iterator::flatten

This adds the trait method `.flatten()` on `Iterator` which flattens one level of nesting from an iterator or (into)iterators. The method `.flat_fmap(f)` is then redefined as `.map(f).flatten()`. The implementation of `Flatten` is essentially that of what it was for `FlatMap` but removing the call to `f` at various places.

Hopefully the type alias approach should be OK as was indicated / alluded to by @bluss and @eddyb in https://github.com/rust-lang/rfcs/pull/2306#issuecomment-361391370.

cc @scottmcm
src/libcore/iter/iterator.rs