Skip to content

Commit 58fe256

Browse files
committed
refactor: simplify pairs using itertools package
1 parent a522cb3 commit 58fe256

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/utils/pair_generator.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1+
use itertools::Itertools;
2+
13
pub fn pairs<T>(list: Vec<T>) -> Vec<(T, T)>
24
where
35
T: Copy,
46
{
5-
list.iter()
6-
.enumerate()
7-
.flat_map(|(i, &a)| list.iter().clone().skip(i + 1).map(move |&b| (a, b)))
8-
.collect()
7+
list.into_iter().tuple_combinations().collect()
98
}
109

1110
#[cfg(test)]

0 commit comments

Comments
 (0)