Closed
Description
In impl Iterator for Combinations
, only the next
method is defined. It shouldn't be too difficult to permit skipping through combinations, so that vec![1, 2, 3, 4].into_iter().combinations(2).nth(4)
doesn't unnecessarily waste time going through the first four iterations just to get to the fifth.
To do this, Combinations
would need a field that kept track of how many iterations have already been made (this may replace the first
bool field), its indices
field would need to be settable immediately depending on the iteration number, and nth
should thus be defined (save some pool-filling).