itertools
itertools copied to clipboard
TupleCollect for N = 0
Currently, it's impossible to use next_tuple and similar tuple methods for unit type, even though such an impl could just return empty tuple on each call, without advancing inner iterator.
Can you say more about why this would be useful to you? I feel like I'd most often want the compiler error here, because if I'm using next_tuple I'm expecting to advance the iterator. Accidentally getting an infinite iterator of units -- which I can't think of why I'd ever want as an adapter, and iter::repeat(()) exists if needed -- feels like it'd be easily error-prone.
Can you say more about why this would be useful to you? I feel like I'd most often want the compiler error here, because if I'm using
next_tupleI'm expecting to advance the iterator. Accidentally getting an infinite iterator of units -- which I can't think of why I'd ever want as an adapter, anditer::repeat(())exists if needed -- feels like it'd be easily error-prone.
At first I wanted to use unit tuples as a placeholder for "Callable that doesn't require any args" in API like this: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=eea1cf14d62513501165abca7fcf11e0. However, the whole idea was wrong and eventually API got changed, since there is also a problem with specifying the item type here: https://github.com/rust-itertools/itertools/blob/master/src/tuple_impl.rs#L271. Quite unsure now if it's even implementable without something like never-type.