rust-itertools / itertools

Extra iterator adaptors, iterator methods, free functions, and macros.
https://docs.rs/itertools/
Apache License 2.0
2.72k stars 309 forks source link

`ZipLongest::fold`: use `try_fold`? #854

Closed Philippe-Cholet closed 9 months ago

Philippe-Cholet commented 9 months ago

Based on https://github.com/rust-itertools/itertools/pull/849#discussion_r1453662745, ZipLongest::fold seems to be the only iterator that might benefit from this idea.

Benchmark specializations on slices is now +13% (still better than no fold specialization) but it might perform better in a more general case.