diff options
| author | bors <bors@rust-lang.org> | 2017-11-17 07:43:08 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-11-17 07:43:08 +0000 |
| commit | b32267f2c1344d37c4aa30eccd5a9ab77642b3e6 (patch) | |
| tree | e19a487ccf691191fa4217b264fe0cf637967ffe /src/rustllvm/RustWrapper.cpp | |
| parent | 3bcb00dbc2edcdc498a9e60a68a14652162d1921 (diff) | |
| parent | b5dba91a19571f28e644a1aa5d60a10d3dd4562b (diff) | |
| download | rust-b32267f2c1344d37c4aa30eccd5a9ab77642b3e6.tar.gz rust-b32267f2c1344d37c4aa30eccd5a9ab77642b3e6.zip | |
Auto merge of #45595 - scottmcm:iter-try-fold, r=dtolnay
Short-circuiting internal iteration with Iterator::try_fold & try_rfold These are the core methods in terms of which the other methods (`fold`, `all`, `any`, `find`, `position`, `nth`, ...) can be implemented, allowing Iterator implementors to get the full goodness of internal iteration by only overriding one method (per direction). Based off the `Try` trait, so works with both `Result` and `Option` (:tada: https://github.com/rust-lang/rust/pull/42526). The `try_fold` rustdoc examples use `Option` and the `try_rfold` ones use `Result`. AKA continuing in the vein of PRs https://github.com/rust-lang/rust/pull/44682 & https://github.com/rust-lang/rust/pull/44856 for more of `Iterator`. New bench following the pattern from the latter of those: ``` test iter::bench_take_while_chain_ref_sum ... bench: 1,130,843 ns/iter (+/- 25,110) test iter::bench_take_while_chain_sum ... bench: 362,530 ns/iter (+/- 391) ``` I also ran the benches without the `fold` & `rfold` overrides to test their new default impls, with basically no change. I left them there, though, to take advantage of existing overrides and because `AlwaysOk` has some sub-optimality due to https://github.com/rust-lang/rust/issues/43278 (which 45225 should fix). If you're wondering why there are three type parameters, see issue https://github.com/rust-lang/rust/issues/45462 Thanks for @bluss for the [original IRLO thread](https://internals.rust-lang.org/t/pre-rfc-fold-ok-is-composable-internal-iteration/4434) and the rfold PR and to @cuviper for adding so many folds, [encouraging me](https://github.com/rust-lang/rust/pull/45379#issuecomment-339424670) to make this PR, and finding a catastrophic bug in a pre-review.
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
0 files changed, 0 insertions, 0 deletions
