rust-itertools / itertools

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

Our non-lazy adaptors #939

Closed Philippe-Cholet closed 1 month ago

Philippe-Cholet commented 1 month ago

Fixes #791

Itertools::{kmerge, kmerge_by, tuple_combinations} are neither lazy nor eager. But they must be used since not doing so does almost nothing (and it would be suspicious code to me). I therefore update the message of the must_use attributes and the laziness tests.

Unless we are willing to roughly wrap those in a LazyInit type (see https://github.com/rust-itertools/itertools/issues/791#issuecomment-1822364744) that would probably slow down iteration ("Is it initialized?" each time next is called), I don't see an alternative.