pythagorean-triplet: Use `&[[u32; 3]]` not `Vec<[u32; 3]>`
Clippy suggested:
warning: this argument is passed by value, but not consumed in the function body
@@ -3,7 +3,7 @@ extern crate pythagorean_triplet;
use pythagorean_triplet::find;
use std::{collections::HashSet, iter::FromIterator};
-fn process_tripletswithsum_case(sum: u32, expected: Vec<[u32; 3]>) {
+fn process_tripletswithsum_case(sum: u32, expected: &[[u32; 3]]) {
let triplets = find(sum);
if !expected.is_empty() {
@@ -17,31 +17,31 @@ fn process_tripletswithsum_case(sum: u32, expected: Vec<[u32; 3]>) {
#[test]
fn test_triplets_whose_sum_is_12() {
- process_tripletswithsum_case(12, vec![[3, 4, 5]]);
+ process_tripletswithsum_case(12, &[[3, 4, 5]]);
}
#[test]
#[ignore]
fn test_triplets_whose_sum_is_108() {
- process_tripletswithsum_case(108, vec![[27, 36, 45]]);
+ process_tripletswithsum_case(108, &[[27, 36, 45]]);
}
#[test]
#[ignore]
fn test_triplets_whose_sum_is_1000() {
- process_tripletswithsum_case(1000, vec![[200, 375, 425]]);
+ process_tripletswithsum_case(1000, &[[200, 375, 425]]);
}
#[test]
#[ignore]
fn test_no_matching_triplets_for_1001() {
- process_tripletswithsum_case(1001, vec![]);
+ process_tripletswithsum_case(1001, &[]);
}
#[test]
#[ignore]
fn test_returns_all_matching_triplets() {
- process_tripletswithsum_case(90, vec![[9, 40, 41], [15, 36, 39]]);
+ process_tripletswithsum_case(90, &[[9, 40, 41], [15, 36, 39]]);
}
#[test]
@@ -49,7 +49,7 @@ fn test_returns_all_matching_triplets() {
fn test_several_matching_triplets() {
process_tripletswithsum_case(
840,
- vec![
+ &[
[40, 399, 401],
[56, 390, 394],
[105, 360, 375],
@@ -67,7 +67,7 @@ fn test_several_matching_triplets() {
fn test_triplets_for_large_number() {
process_tripletswithsum_case(
30000,
- vec![
+ &[
[1200, 14375, 14425],
[1875, 14000, 14125],
[5000, 12000, 13000],
