Can you use that on this function too?
// pairwise(1 2 3) => (1, 1) (1, 2) (1, 3) (2, 2) (2, 3) (3, 3)
fn pairwise<'a, T>(items: &'a [T]) -> impl Iterator<Item=(&'a T, &'a T)> + 'a {
items
.iter()
.enumerate()
.flat_map(move |(i, x1)| items[i ..]
.iter()
.map(move |x2| (x1, x2)))
}