Does itertools::Combinations makes any guarantees about the order in which it yields combinations?
The docs provide this example:
use itertools::Itertools;
let it = (1..5).combinations(3);
itertools::assert_equal(it, vec![
vec![1, 2, 3],
vec![1, 2, 4],
vec![1, 3, 4],
vec![2, 3, 4],
]);
Which at a glance is constructing the combinations by "indexing" the iterator (1..5) with lexicographically sorted indices [0, 1, 2], [0, 1, 3], [0, 2, 3], and [1, 2, 3].
I am wondering if this is something I can rely on, or if it is an implementation detail that should not be relied on?
Does
itertools::Combinationsmakes any guarantees about the order in which it yields combinations?The docs provide this example:
Which at a glance is constructing the combinations by "indexing" the iterator
(1..5)with lexicographically sorted indices[0, 1, 2],[0, 1, 3],[0, 2, 3], and[1, 2, 3].I am wondering if this is something I can rely on, or if it is an implementation detail that should not be relied on?