next and next_back are now based on find_map instead of "while-next" loops. It would be useful performance-wise for iterators specializing try_[r]fold. I intend to do the same for other while-next loops (where benchmarks show times decrease, up to -20%).
Stable benchmarks here.
Doing this, I first made a silly mistake. I therefore add a test that would have helped me, and fix a little error in the documentation (it could alternatively use filter_map to avoid * copy).
Following https://github.com/rust-itertools/itertools/pull/813#issuecomment-1847585114, with this PR,
Positions
now usesEnumerate
internally.next
andnext_back
are now based onfind_map
instead of "while-next" loops. It would be useful performance-wise for iterators specializingtry_[r]fold
. I intend to do the same for other while-next loops (where benchmarks show times decrease, up to -20%).filter_map
to avoid*
copy).