From c2c38718e48cd12d475e4c69dcb85041f411bade Mon Sep 17 00:00:00 2001 From: pm Date: Tue, 3 Feb 2026 20:16:30 +0100 Subject: [PATCH 1/6] Deprecate tuple_combinations (1) As per https://github.com/rust-itertools/itertools/issues/1084#issuecomment-3832305846 --- src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib.rs b/src/lib.rs index 36ddef6cc..604c34c09 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1710,6 +1710,7 @@ pub trait Itertools: Iterator { /// let it: TupleCombinations, (u32, u32, u32)> = (1..5).tuple_combinations(); /// itertools::assert_equal(it, vec![(1, 2, 3), (1, 2, 4), (1, 3, 4), (2, 3, 4)]); /// ``` + #[deprecated(note = "Use .array_combinations() instead", since = "0.15.0")] fn tuple_combinations(self) -> TupleCombinations where Self: Sized, From 37da7ddac603bb5003d1890faf0275f68e9bb243 Mon Sep 17 00:00:00 2001 From: pm Date: Tue, 3 Feb 2026 20:21:39 +0100 Subject: [PATCH 2/6] Deprecate tuple_combinations (2) benches --- benches/specializations.rs | 16 +++++----- benches/tuple_combinations.rs | 56 +++++++++++++++++------------------ 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/benches/specializations.rs b/benches/specializations.rs index 2b9eff6d1..247b61481 100644 --- a/benches/specializations.rs +++ b/benches/specializations.rs @@ -355,29 +355,29 @@ bench_specializations! { } v.iter().copied().update(|x| *x *= 7) } - tuple_combinations1 { + array_combinations1 { { let v = black_box(vec![0; 1024]); } - v.iter().tuple_combinations::<(_,)>() + v.iter().array_combinations::<1>() } - tuple_combinations2 { + array_combinations2 { { let v = black_box(vec![0; 64]); } - v.iter().tuple_combinations::<(_, _)>() + v.iter().array_combinations::<2>() } - tuple_combinations3 { + array_combinations3 { { let v = black_box(vec![0; 64]); } - v.iter().tuple_combinations::<(_, _, _)>() + v.iter().array_combinations::<3>() } - tuple_combinations4 { + array_combinations4 { { let v = black_box(vec![0; 64]); } - v.iter().tuple_combinations::<(_, _, _, _)>() + v.iter().array_combinations::<4>() } intersperse { { diff --git a/benches/tuple_combinations.rs b/benches/tuple_combinations.rs index 4e26b282e..407a97856 100644 --- a/benches/tuple_combinations.rs +++ b/benches/tuple_combinations.rs @@ -7,8 +7,8 @@ const N2: usize = 448; const N3: usize = 86; const N4: usize = 41; -fn tuple_comb_for1(c: &mut Criterion) { - c.bench_function("tuple comb for1", move |b| { +fn array_comb_for1(c: &mut Criterion) { + c.bench_function("array comb for1", move |b| { b.iter(|| { for i in 0..N1 { black_box(i); @@ -17,8 +17,8 @@ fn tuple_comb_for1(c: &mut Criterion) { }); } -fn tuple_comb_for2(c: &mut Criterion) { - c.bench_function("tuple comb for2", move |b| { +fn array_comb_for2(c: &mut Criterion) { + c.bench_function("array comb for2", move |b| { b.iter(|| { for i in 0..N2 { for j in (i + 1)..N2 { @@ -29,8 +29,8 @@ fn tuple_comb_for2(c: &mut Criterion) { }); } -fn tuple_comb_for3(c: &mut Criterion) { - c.bench_function("tuple comb for3", move |b| { +fn array_comb_for3(c: &mut Criterion) { + c.bench_function("array comb for3", move |b| { b.iter(|| { for i in 0..N3 { for j in (i + 1)..N3 { @@ -43,8 +43,8 @@ fn tuple_comb_for3(c: &mut Criterion) { }); } -fn tuple_comb_for4(c: &mut Criterion) { - c.bench_function("tuple comb for4", move |b| { +fn array_comb_for4(c: &mut Criterion) { + c.bench_function("array comb for4", move |b| { b.iter(|| { for i in 0..N4 { for j in (i + 1)..N4 { @@ -59,40 +59,40 @@ fn tuple_comb_for4(c: &mut Criterion) { }); } -fn tuple_comb_c1(c: &mut Criterion) { - c.bench_function("tuple comb c1", move |b| { +fn array_comb_c1(c: &mut Criterion) { + c.bench_function("array comb c1", move |b| { b.iter(|| { - for (i,) in (0..N1).tuple_combinations() { + for [i] in (0..N1).array_combinations() { black_box(i); } }) }); } -fn tuple_comb_c2(c: &mut Criterion) { - c.bench_function("tuple comb c2", move |b| { +fn array_comb_c2(c: &mut Criterion) { + c.bench_function("array comb c2", move |b| { b.iter(|| { - for (i, j) in (0..N2).tuple_combinations() { + for [i, j] in (0..N2).array_combinations() { black_box(i + j); } }) }); } -fn tuple_comb_c3(c: &mut Criterion) { - c.bench_function("tuple comb c3", move |b| { +fn array_comb_c3(c: &mut Criterion) { + c.bench_function("array comb c3", move |b| { b.iter(|| { - for (i, j, k) in (0..N3).tuple_combinations() { + for [i, j, k] in (0..N3).array_combinations() { black_box(i + j + k); } }) }); } -fn tuple_comb_c4(c: &mut Criterion) { - c.bench_function("tuple comb c4", move |b| { +fn array_comb_c4(c: &mut Criterion) { + c.bench_function("array comb c4", move |b| { b.iter(|| { - for (i, j, k, l) in (0..N4).tuple_combinations() { + for [i, j, k, l] in (0..N4).array_combinations() { black_box(i + j + k + l); } }) @@ -101,13 +101,13 @@ fn tuple_comb_c4(c: &mut Criterion) { criterion_group!( benches, - tuple_comb_for1, - tuple_comb_for2, - tuple_comb_for3, - tuple_comb_for4, - tuple_comb_c1, - tuple_comb_c2, - tuple_comb_c3, - tuple_comb_c4, + array_comb_for1, + array_comb_for2, + array_comb_for3, + array_comb_for4, + array_comb_c1, + array_comb_c2, + array_comb_c3, + array_comb_c4, ); criterion_main!(benches); From 39b58e64de955517afb3df651301e56c69ff6860 Mon Sep 17 00:00:00 2001 From: pm Date: Tue, 3 Feb 2026 20:22:39 +0100 Subject: [PATCH 3/6] Deprecate tuple_combinations (3) examples --- examples/iris.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/iris.rs b/examples/iris.rs index fe783b9b7..f89f2e3ae 100644 --- a/examples/iris.rs +++ b/examples/iris.rs @@ -99,8 +99,8 @@ fn main() { let n = 30; // plot size let mut plot = vec![' '; n * n]; - // using Itertools::tuple_combinations - for (a, b) in (0..4).tuple_combinations() { + // using Itertools::array_combinations + for [a, b] in (0..4).array_combinations() { println!("Column {a} vs {b}:"); // Clear plot From 6c68ab1b10f4d12d2160c9a1856484d695b76c16 Mon Sep 17 00:00:00 2001 From: pm Date: Tue, 3 Feb 2026 20:28:50 +0100 Subject: [PATCH 4/6] Deprecate tuple_combinations (4) test_std I left the original tests, and added their array_combination counterparts. --- tests/test_std.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/test_std.rs b/tests/test_std.rs index dc0c163ba..ab6853065 100644 --- a/tests/test_std.rs +++ b/tests/test_std.rs @@ -1066,9 +1066,15 @@ fn combinations() { ], ); - it::assert_equal((0..0).tuple_combinations::<(_, _)>(), >::new()); - it::assert_equal((0..1).tuple_combinations::<(_, _)>(), >::new()); - it::assert_equal((0..2).tuple_combinations::<(_, _)>(), vec![(0, 1)]); + #[allow(deprecated)] + { + it::assert_equal((0..0).tuple_combinations::<(_, _)>(), >::new()); + it::assert_equal((0..1).tuple_combinations::<(_, _)>(), >::new()); + it::assert_equal((0..2).tuple_combinations::<(_, _)>(), vec![(0, 1)]); + } + it::assert_equal((0..0).array_combinations::<2>(), >::new()); + it::assert_equal((0..1).array_combinations::<2>(), >::new()); + it::assert_equal((0..2).array_combinations::<2>(), vec![[0, 1]]); it::assert_equal((0..0).combinations(2), >>::new()); it::assert_equal((0..1).combinations(1), vec![vec![0]]); From c15ded20ba5d3a0d65daf8f2a07041476364214c Mon Sep 17 00:00:00 2001 From: pm Date: Tue, 3 Feb 2026 20:31:04 +0100 Subject: [PATCH 5/6] Deprecate tuple_combinations (5) specialization tests I left the original tests, array_combination counterparts already present. --- tests/specializations.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/specializations.rs b/tests/specializations.rs index 26d1f5367..2c53cf7ae 100644 --- a/tests/specializations.rs +++ b/tests/specializations.rs @@ -255,6 +255,7 @@ quickcheck! { test_double_ended_specializations(&it); } + #[allow(deprecated)] fn tuple_combinations(v: Vec) -> TestResult { if v.len() > 10 { return TestResult::discard(); From 4c0a468dd7014b933441114b0feea4055223025a Mon Sep 17 00:00:00 2001 From: pm Date: Tue, 3 Feb 2026 20:50:44 +0100 Subject: [PATCH 6/6] Deprecate tuple_combinations (6) tests/laziness I left the original tests, and added their array_combination counterparts. Note that they do not panic, and I saw no reason why they should. --- tests/laziness.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/laziness.rs b/tests/laziness.rs index dfeee68f8..a4b4f138e 100644 --- a/tests/laziness.rs +++ b/tests/laziness.rs @@ -196,17 +196,29 @@ must_use_tests! { while_some { let _ = Panicking.map(Some).while_some(); } + #[allow(deprecated)] tuple_combinations1 { let _ = Panicking.tuple_combinations::<(_,)>(); } + #[allow(deprecated)] #[should_panic] tuple_combinations2 { let _ = Panicking.tuple_combinations::<(_, _)>(); } + #[allow(deprecated)] #[should_panic] tuple_combinations3 { let _ = Panicking.tuple_combinations::<(_, _, _)>(); } + array_combinations1 { + let _ = Panicking.array_combinations::<1>(); + } + array_combinations2 { + let _ = Panicking.array_combinations::<2>(); + } + array_combinations3 { + let _ = Panicking.array_combinations::<3>(); + } combinations { let _ = Panicking.combinations(0); let _ = Panicking.combinations(1);