fn comp(a: Vec, b: Vec) -> bool { let mut a = a.into_iter().map(|x| x * x).collect::>(); let mut b = b; a.sort(); b.sort(); a == b } fn testing(a: Vec, b: Vec, exp: bool) -> () { assert_eq!(comp(a, b), exp) } #[test] fn tests_comp() { let a1 = vec![121, 144, 19, 161, 19, 144, 19, 11]; let a2 = vec![ 11 * 11, 121 * 121, 144 * 144, 19 * 19, 161 * 161, 19 * 19, 144 * 144, 19 * 19, ]; testing(a1, a2, true); let a1 = vec![121, 144, 19, 161, 19, 144, 19, 11]; let a2 = vec![ 11 * 21, 121 * 121, 144 * 144, 19 * 19, 161 * 161, 19 * 19, 144 * 144, 19 * 19, ]; testing(a1, a2, false); let a1 = vec![121, 144, 19, 161, -19, 144, 19, -11]; let a2 = vec![ 11 * 11, 121 * 121, 144 * 144, 19 * 19, 161 * 161, 19 * 19, 144 * 144, 19 * 19, ]; testing(a1, a2, true); }