rust/src/libcore/tests
bors b32267f2c1 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` (🎉 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.
2017-11-17 07:43:08 +00:00
..
fmt Move libXtest into libX/tests 2017-04-03 20:49:39 +02:00
hash Implement Hash for raw pointers to unsized types 2017-10-25 11:07:13 -07:00
num std: Remove rand crate and module 2017-11-08 20:41:17 -08:00
any.rs Move libXtest into libX/tests 2017-04-03 20:49:39 +02:00
array.rs Try to fix array TryFrom tests 2017-09-24 14:54:04 -04:00
atomic.rs Optimize AtomicBool::fetch_nand 2017-04-07 17:36:50 +02:00
cell.rs Implement RefCell::replace and RefCell::swap 2017-07-31 21:19:09 +00:00
char.rs Remove test case that assumes FromStr provides TryFrom<&'a str>. 2017-08-30 04:43:09 -07:00
clone.rs Move libXtest into libX/tests 2017-04-03 20:49:39 +02:00
cmp.rs Add max and min default fns to Ord trait 2017-06-06 22:42:48 -04:00
intrinsics.rs Move libXtest into libX/tests 2017-04-03 20:49:39 +02:00
iter.rs Fundamental internal iteration with try_fold 2017-10-29 15:45:20 -07:00
lib.rs Fundamental internal iteration with try_fold 2017-10-29 15:45:20 -07:00
mem.rs core: Ensure std::mem::Discriminant is Send + Sync 2017-10-08 01:09:55 +02:00
nonzero.rs Rename {NonZero,Shared,Unique}::new to new_unchecked 2017-07-22 20:38:16 +02:00
ops.rs Return a correct size_hint for degenerate inclusive ranges 2017-05-21 05:03:49 -07:00
option.rs Rename option::Missing to NoneError 2017-09-27 17:57:07 -04:00
ptr.rs Restore T: Sized on ptr::is_null 2017-10-10 11:35:41 -07:00
result.rs Rename option::Missing to NoneError 2017-09-27 17:57:07 -04:00
slice.rs Auto merge of #45595 - scottmcm:iter-try-fold, r=dtolnay 2017-11-17 07:43:08 +00:00
str.rs Move libXtest into libX/tests 2017-04-03 20:49:39 +02:00
tuple.rs Move libXtest into libX/tests 2017-04-03 20:49:39 +02:00