]> git.lizzy.rs Git - rust.git/commitdiff
Auto merge of #37315 - bluss:fold-more, r=alexcrichton
authorbors <bors@rust-lang.org>
Wed, 26 Oct 2016 18:43:32 +0000 (11:43 -0700)
committerGitHub <noreply@github.com>
Wed, 26 Oct 2016 18:43:32 +0000 (11:43 -0700)
Implement Iterator::fold for .chain(), .cloned(), .map() and the VecDeque iterators.

Chain can do something interesting here where it passes on the fold
into its inner iterators.

The lets the underlying iterator's custom fold() be used, and skips the
regular chain logic in next.

Also implement .fold() specifically for .map() and .cloned() so that any
inner fold improvements are available through map and cloned.

The same way, a VecDeque iterator fold can be turned into two slice folds.

These changes lend the power of the slice iterator's loop codegen to
VecDeque, and to chains of slice iterators, and so on.
It's an improvement for .sum() and .product(), and other uses of fold.


Trivial merge