Is there a reasonable way of producing the product of iterators similar to Python's itertools.product
function?
For example is there some reasonable or canonical way of taking (0..2, 3)
as input and producing an iterator with values (0,0,0)
, (0,0,1)
, (0,1,0)
, (0,1,1)
, (1,0,0)
, (1,0,1)
, (1,1,0)
, (1,1,1)
as a result?
I've already created an iterator which produces the product of two iterators, but I'm especially interested in iterating over powers of an iterator similar to a nested for loop where the depth of nesting is determined at runtime, so I'd rather not be creating separate struct
s for each number of iterators in the product (and I'd like to have powers up to at least u8
size).
Excellent, thank you! I hadn't thought to look beyond the standard library for some stupid reason.