From 2f0ba9f98faacc682da8cc39ae82f510f8061d3a Mon Sep 17 00:00:00 2001 From: Nicholas Ward Date: Tue, 14 Sep 2021 13:27:17 -0700 Subject: [PATCH] cleanup (references) --- src/gates/comparison.rs | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/gates/comparison.rs b/src/gates/comparison.rs index 38ad9429..850fa311 100644 --- a/src/gates/comparison.rs +++ b/src/gates/comparison.rs @@ -98,12 +98,12 @@ impl, const D: usize> Gate for ComparisonGate let first_chunks_combined = first_chunks .iter() .zip(chunk_base_powers.iter()) - .map(|(b, x)| *b * *x) + .map(|(&b, &x)| b * x) .fold(F::Extension::ZERO, |a, b| a + b); let second_chunks_combined = second_chunks .iter() .zip(chunk_base_powers.iter()) - .map(|(b, x)| *b * *x) + .map(|(&b, &x)| b * x) .fold(F::Extension::ZERO, |a, b| a + b); constraints.push(first_chunks_combined - first_input); @@ -136,7 +136,7 @@ impl, const D: usize> Gate for ComparisonGate let z_bits_combined = z_bits .iter() .zip(powers_of_two.iter()) - .map(|(b, x)| *b * *x) + .map(|(&b, &x)| b * x) .fold(F::Extension::ZERO, |a, b| a + b); let two_n = F::Extension::TWO.exp_u64(self.chunk_bits() as u64); @@ -243,7 +243,7 @@ impl, const D: usize> SimpleGenerator .map(|bits| { bits.iter() .zip(powers_of_two.iter()) - .map(|(b, x)| *b * *x) + .map(|(&b, &x)| b * x) .fold(F::ZERO, |a, b| a + b) }) .collect(); @@ -252,7 +252,7 @@ impl, const D: usize> SimpleGenerator .map(|bits| { bits.iter() .zip(powers_of_two.iter()) - .map(|(b, x)| *b * *x) + .map(|(&b, &x)| b * x) .fold(F::ZERO, |a, b| a + b) }) .collect(); @@ -411,7 +411,7 @@ mod tests { .map(|bits| { bits.iter() .zip(powers_of_two.iter()) - .map(|(b, x)| *b * *x) + .map(|(&b, &x)| b * x) .fold(F::ZERO, |a, b| a + b) }) .collect(); @@ -420,7 +420,7 @@ mod tests { .map(|bits| { bits.iter() .zip(powers_of_two.iter()) - .map(|(b, x)| *b * *x) + .map(|(&b, &x)| b * x) .fold(F::ZERO, |a, b| a + b) }) .collect(); @@ -431,7 +431,7 @@ mod tests { let mut equality_dummies: Vec = first_input_chunks .iter() .zip(second_input_chunks.iter()) - .map(|(f, s)| if *f == *s { F::ONE } else { F::ONE / (*f - *s) }) + .map(|(&f, &s)| if f == s { F::ONE } else { F::ONE / (f - s) }) .collect(); let mut diff_index = 0; @@ -467,9 +467,7 @@ mod tests { let mut rng = rand::thread_rng(); let max: u64 = 1 << num_bits - 1; - let first_inputs_u64: Vec = (0..num_copies) - .map(|_| rng.gen_range(0..max)) - .collect(); + let first_inputs_u64: Vec = (0..num_copies).map(|_| rng.gen_range(0..max)).collect(); let second_inputs_u64: Vec = (0..num_copies) .map(|i| { let mut val = rng.gen_range(0..max); @@ -479,9 +477,15 @@ mod tests { val }) .collect(); - - let first_inputs = first_inputs_u64.iter().map(|&x| F::from_canonical_u64(x)).collect(); - let second_inputs = second_inputs_u64.iter().map(|&x| F::from_canonical_u64(x)).collect(); + + let first_inputs = first_inputs_u64 + .iter() + .map(|&x| F::from_canonical_u64(x)) + .collect(); + let second_inputs = second_inputs_u64 + .iter() + .map(|&x| F::from_canonical_u64(x)) + .collect(); let gate = ComparisonGate:: { num_bits,