rust/src
bors 09ee9b723a Auto merge of #44856 - cuviper:more-fold, r=dtolnay
Add more custom folding to `core::iter` adaptors

Many of the iterator adaptors will perform faster folds if they forward
to their inner iterator's folds, especially for inner types like `Chain`
which are optimized too.  The following types are newly specialized:

| Type        | `fold` | `rfold` |
| ----------- | ------ | ------- |
| `Enumerate` | ✓      | ✓       |
| `Filter`    | ✓      | ✓       |
| `FilterMap` | ✓      | ✓       |
| `FlatMap`   | exists | ✓       |
| `Fuse`      | ✓      | ✓       |
| `Inspect`   | ✓      | ✓       |
| `Peekable`  | ✓      | N/A¹    |
| `Skip`      | ✓      | N/A²    |
| `SkipWhile` | ✓      | N/A¹    |

¹ not a `DoubleEndedIterator`

² `Skip::next_back` doesn't pull skipped items at all, but this couldn't
be avoided if `Skip::rfold` were to call its inner iterator's `rfold`.

Benchmarks
----------

In the following results, plain `_sum` computes the sum of a million
integers -- note that `sum()` is implemented with `fold()`.  The
`_ref_sum` variants do the same on a `by_ref()` iterator, which is
limited to calling `next()` one by one, without specialized `fold`.

The `chain` variants perform the same tests on two iterators chained
together, to show a greater benefit of forwarding `fold` internally.

    test iter::bench_enumerate_chain_ref_sum  ... bench:   2,216,264 ns/iter (+/- 29,228)
    test iter::bench_enumerate_chain_sum      ... bench:     922,380 ns/iter (+/- 2,676)
    test iter::bench_enumerate_ref_sum        ... bench:     476,094 ns/iter (+/- 7,110)
    test iter::bench_enumerate_sum            ... bench:     476,438 ns/iter (+/- 3,334)

    test iter::bench_filter_chain_ref_sum     ... bench:   2,266,095 ns/iter (+/- 6,051)
    test iter::bench_filter_chain_sum         ... bench:     745,594 ns/iter (+/- 2,013)
    test iter::bench_filter_ref_sum           ... bench:     889,696 ns/iter (+/- 1,188)
    test iter::bench_filter_sum               ... bench:     667,325 ns/iter (+/- 1,894)

    test iter::bench_filter_map_chain_ref_sum ... bench:   2,259,195 ns/iter (+/- 353,440)
    test iter::bench_filter_map_chain_sum     ... bench:   1,223,280 ns/iter (+/- 1,972)
    test iter::bench_filter_map_ref_sum       ... bench:     611,607 ns/iter (+/- 2,507)
    test iter::bench_filter_map_sum           ... bench:     611,610 ns/iter (+/- 472)

    test iter::bench_fuse_chain_ref_sum       ... bench:   2,246,106 ns/iter (+/- 22,395)
    test iter::bench_fuse_chain_sum           ... bench:     634,887 ns/iter (+/- 1,341)
    test iter::bench_fuse_ref_sum             ... bench:     444,816 ns/iter (+/- 1,748)
    test iter::bench_fuse_sum                 ... bench:     316,954 ns/iter (+/- 2,616)

    test iter::bench_inspect_chain_ref_sum    ... bench:   2,245,431 ns/iter (+/- 21,371)
    test iter::bench_inspect_chain_sum        ... bench:     631,645 ns/iter (+/- 4,928)
    test iter::bench_inspect_ref_sum          ... bench:     317,437 ns/iter (+/- 702)
    test iter::bench_inspect_sum              ... bench:     315,942 ns/iter (+/- 4,320)

    test iter::bench_peekable_chain_ref_sum   ... bench:   2,243,585 ns/iter (+/- 12,186)
    test iter::bench_peekable_chain_sum       ... bench:     634,848 ns/iter (+/- 1,712)
    test iter::bench_peekable_ref_sum         ... bench:     444,808 ns/iter (+/- 480)
    test iter::bench_peekable_sum             ... bench:     317,133 ns/iter (+/- 3,309)

    test iter::bench_skip_chain_ref_sum       ... bench:   1,778,734 ns/iter (+/- 2,198)
    test iter::bench_skip_chain_sum           ... bench:     761,850 ns/iter (+/- 1,645)
    test iter::bench_skip_ref_sum             ... bench:     478,207 ns/iter (+/- 119,252)
    test iter::bench_skip_sum                 ... bench:     315,614 ns/iter (+/- 3,054)

    test iter::bench_skip_while_chain_ref_sum ... bench:   2,486,370 ns/iter (+/- 4,845)
    test iter::bench_skip_while_chain_sum     ... bench:     633,915 ns/iter (+/- 5,892)
    test iter::bench_skip_while_ref_sum       ... bench:     666,926 ns/iter (+/- 804)
    test iter::bench_skip_while_sum           ... bench:     444,405 ns/iter (+/- 571)
2017-09-29 12:56:24 +00:00
..
bootstrap Auto merge of #44785 - alexcrichton:update-cargo, r=nikomatsakis 2017-09-28 16:19:58 +00:00
build_helper Add a file to trivially disable tool building or testing 2017-09-17 21:41:45 +02:00
ci Auto merge of #44779 - tjkirch:master, r=alexcrichton 2017-09-28 03:28:20 +00:00
doc Add support for ..= syntax 2017-09-22 22:05:18 +02:00
etc Rollup merge of #44351 - lu-zero:master, r=nikomatsakis 2017-09-06 18:28:03 -06:00
grammar
jemalloc@1f5a28755e Update jemalloc to 4.5.0 2017-08-16 22:06:05 +02:00
liballoc Auto merge of #44709 - Badel2:inclusive-range-dotdoteq, r=petrochenkov 2017-09-27 16:04:31 +00:00
liballoc_jemalloc Update to the cc crate 2017-09-28 07:45:50 -07:00
liballoc_system Autodetect the type of allocator crate used 2017-09-10 19:59:42 +02:00
libarena stabilized needs_drop (fixes #41890) 2017-09-16 23:41:04 +02:00
libbacktrace Fix missing line numbers on i686. 2017-09-05 08:41:43 +08:00
libcollections *: remove crate_{name,type} attributes 2017-08-25 16:18:21 -04:00
libcompiler_builtins@ef4951582f Update submodules. 2017-09-24 13:53:10 -07:00
libcore Auto merge of #44856 - cuviper:more-fold, r=dtolnay 2017-09-29 12:56:24 +00:00
libfmt_macros *: remove crate_{name,type} attributes 2017-08-25 16:18:21 -04:00
libgetopts *: remove crate_{name,type} attributes 2017-08-25 16:18:21 -04:00
libgraphviz *: remove crate_{name,type} attributes 2017-08-25 16:18:21 -04:00
liblibc@44e4018e1a bump liblibc to 0.2.31 2017-09-24 13:53:11 -07:00
libpanic_abort *: remove crate_{name,type} attributes 2017-08-25 16:18:21 -04:00
libpanic_unwind Add missing dependency for Windows 2017-08-27 19:02:24 +09:00
libproc_macro Add support for ..= syntax 2017-09-22 22:05:18 +02:00
libprofiler_builtins Update to the cc crate 2017-09-28 07:45:50 -07:00
librand *: remove crate_{name,type} attributes 2017-08-25 16:18:21 -04:00
librustc Auto merge of #44853 - alexcrichton:debug-codegen-units, r=michaelwoerister 2017-09-29 10:10:15 +00:00
librustc_allocator Make fields of Span private 2017-08-30 01:38:54 +03:00
librustc_apfloat Remove rustc_bitflags; use the bitflags crate 2017-09-17 14:19:24 -04:00
librustc_asan
librustc_back add aarch64-unknown-linux-musl target 2017-09-23 14:46:33 -07:00
librustc_borrowck Only consider yields coming after the expressions when computing generator interiors 2017-09-20 16:36:24 +03:00
librustc_const_eval incr.comp.: Already hash HIR bodies during metadata export so they don't have to be hashed in downstream crates. 2017-09-18 11:26:11 +02:00
librustc_const_math change #![feature(const_fn)] to specific gates 2017-09-16 15:53:02 +00:00
librustc_cratesio_shim Remove rustc_bitflags; use the bitflags crate 2017-09-17 14:19:24 -04:00
librustc_data_structures Point at parameter type on E0301 2017-09-24 11:50:09 -07:00
librustc_driver Auto merge of #44085 - bjorn3:no_llvm_write_metadata, r=arielb1 2017-09-25 18:05:22 +00:00
librustc_errors Fix mispositioned error indicators 2017-09-07 10:26:27 +02:00
librustc_incremental incr.comp.: Remove out-dated unit test and unnecessary assertion. 2017-09-23 19:49:05 +02:00
librustc_lint add comparison operators to must-use lint (under fn_must_use feature) 2017-09-22 15:45:47 -07:00
librustc_llvm Update to the cc crate 2017-09-28 07:45:50 -07:00
librustc_lsan
librustc_metadata incr.comp.: Remove support for loading metadata fingerprints. 2017-09-23 19:47:37 +02:00
librustc_mir Auto merge of #44811 - zilbuz:issue-44596/E0506, r=arielb1 2017-09-29 03:54:12 +00:00
librustc_msan
librustc_passes Implement underscore lifetimes 2017-09-20 23:45:05 -07:00
librustc_platform_intrinsics Rollup merge of #44351 - lu-zero:master, r=nikomatsakis 2017-09-06 18:28:03 -06:00
librustc_plugin *: remove crate_{name,type} attributes 2017-08-25 16:18:21 -04:00
librustc_privacy Use recorded types in rustc_privacy 2017-09-23 00:50:46 +03:00
librustc_resolve Auto merge of #44215 - oli-obk:import_sugg, r=nrc 2017-09-21 20:12:22 +00:00
librustc_save_analysis Use NodeId/HirId instead of DefId for local variables. 2017-09-08 22:00:59 +03:00
librustc_trans Auto merge of #44853 - alexcrichton:debug-codegen-units, r=michaelwoerister 2017-09-29 10:10:15 +00:00
librustc_trans_utils Fix error 2017-09-25 08:17:37 +02:00
librustc_tsan Move unused-extern-crate to late pass 2017-08-27 19:02:24 +09:00
librustc_typeck Auto merge of #44297 - laumann:suggest-misspelt-methods, r=arielb1 2017-09-25 23:09:06 +00:00
librustdoc Update to the cc crate 2017-09-28 07:45:50 -07:00
libserialize *: remove crate_{name,type} attributes 2017-08-25 16:18:21 -04:00
libstd Auto merge of #44278 - Binero:master, r=BurntSushi 2017-09-28 18:52:49 +00:00
libstd_unicode [libstd_unicode] Expose UnicodeVersion type 2017-09-18 20:39:17 -07:00
libsyntax Auto merge of #44528 - tmnilsson:attr_proc_macro_cfg_process, r=jseyfried 2017-09-28 23:38:52 +00:00
libsyntax_ext only set non-ADT derive error once per attribute, not per trait 2017-09-21 21:20:23 -07:00
libsyntax_pos Compress "small" spans to 32 bits and intern "large" spans 2017-09-23 00:34:13 +03:00
libterm *: remove crate_{name,type} attributes 2017-08-25 16:18:21 -04:00
libtest Platform gate libc in libtest 2017-08-27 19:02:24 +09:00
libunwind *: remove crate_{name,type} attributes 2017-08-25 16:18:21 -04:00
llvm@d9e7d2696e
rt
rtstartup
rustc Trim and document libc shim 2017-09-21 22:25:02 -04:00
rustllvm Add 'native' to -C target-cpu=help 2017-09-15 00:32:59 -05:00
test Auto merge of #44853 - alexcrichton:debug-codegen-units, r=michaelwoerister 2017-09-29 10:10:15 +00:00
tools Auto merge of #44785 - alexcrichton:update-cargo, r=nikomatsakis 2017-09-28 16:19:58 +00:00
Cargo.lock Update to the cc crate 2017-09-28 07:45:50 -07:00
Cargo.toml Update to the cc crate 2017-09-28 07:45:50 -07:00
stage0.txt Bump to 1.22.0 2017-08-31 06:58:58 -07:00