From e3f5d3eb7bded7ef7a3c6294fd84758bc44a3763 Mon Sep 17 00:00:00 2001 From: Stephen Waits Date: Mon, 4 May 2026 19:28:08 -0600 Subject: [PATCH] chore: silence clippy warnings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - pareto/crowding.rs: rewrite the inner loop to iterate per-objective via index_axis-style indexing on `oriented` rather than naming an unused loop variable `k`. - operators/{binary,permutation}.rs tests: pass parents via `std::slice::from_ref` instead of `&[parent.clone()]` to avoid the cloned_ref_to_slice_refs lint. Pure cleanup — no behavior change, all 83 unit tests + 2 doctests still pass. --- src/operators/binary.rs | 4 ++-- src/operators/permutation.rs | 6 +++--- src/pareto/crowding.rs | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/operators/binary.rs b/src/operators/binary.rs index 1bd83d0..e39c8b8 100644 --- a/src/operators/binary.rs +++ b/src/operators/binary.rs @@ -45,7 +45,7 @@ mod tests { let mut m = BitFlipMutation { probability: 0.0 }; let mut rng = rng_from_seed(0); let parent = vec![false, true, false, true, true]; - let children = m.vary(&[parent.clone()], &mut rng); + let children = m.vary(std::slice::from_ref(&parent), &mut rng); assert_eq!(children.len(), 1); assert_eq!(children[0], parent); } @@ -55,7 +55,7 @@ mod tests { let mut m = BitFlipMutation { probability: 1.0 }; let mut rng = rng_from_seed(0); let parent = vec![false, true, false, true, true]; - let children = m.vary(&[parent.clone()], &mut rng); + let children = m.vary(std::slice::from_ref(&parent), &mut rng); let expected: Vec = parent.iter().map(|b| !b).collect(); assert_eq!(children[0], expected); } diff --git a/src/operators/permutation.rs b/src/operators/permutation.rs index 987648e..e200ff3 100644 --- a/src/operators/permutation.rs +++ b/src/operators/permutation.rs @@ -46,7 +46,7 @@ mod tests { let mut m = SwapMutation; let mut rng = rng_from_seed(11); let parent = vec![0_usize, 1, 2, 3, 4]; - let children = m.vary(&[parent.clone()], &mut rng); + let children = m.vary(std::slice::from_ref(&parent), &mut rng); assert_eq!(children.len(), 1); assert_eq!(sorted(children[0].clone()), sorted(parent)); } @@ -56,7 +56,7 @@ mod tests { let mut m = SwapMutation; let mut rng = rng_from_seed(0); let parent = vec![42_usize]; - let children = m.vary(&[parent.clone()], &mut rng); + let children = m.vary(std::slice::from_ref(&parent), &mut rng); assert_eq!(children[0], parent); } @@ -65,7 +65,7 @@ mod tests { let mut m = SwapMutation; let mut rng = rng_from_seed(0); let parent = vec![1_usize, 2]; - let children = m.vary(&[parent.clone()], &mut rng); + let children = m.vary(std::slice::from_ref(&parent), &mut rng); assert_eq!(children[0], vec![2, 1]); } } diff --git a/src/pareto/crowding.rs b/src/pareto/crowding.rs index dfba462..bdefac1 100644 --- a/src/pareto/crowding.rs +++ b/src/pareto/crowding.rs @@ -33,6 +33,7 @@ pub fn crowding_distance( .map(|&idx| objectives.as_minimization(&population[idx].evaluation.objectives)) .collect(); + #[allow(clippy::needless_range_loop)] // `k` indexes into nested vectors below. for k in 0..m { // Sort indices into `front` by objective k. let mut order: Vec = (0..n).collect();