Use built-in iteration functions more
François Garillot francois@garillot.net
Mon, 02 Dec 2019 07:28:49 -0800
5 files changed,
6 insertions(+),
9 deletions(-)
M
crypto-primitives/src/crh/bowe_hopwood/mod.rs
→
crypto-primitives/src/crh/bowe_hopwood/mod.rs
@@ -144,9 +144,9 @@ encoded = encoded.neg();
} encoded }) - .reduce(|| G::zero(), |a, b| a + &b) + .reduce(G::zero, |a, b| a + &b) }) - .reduce(|| G::zero(), |a, b| a + &b); + .reduce(G::zero, |a, b| a + &b); end_timer!(eval_time); Ok(result)
M
crypto-primitives/src/crh/pedersen/mod.rs
→
crypto-primitives/src/crh/pedersen/mod.rs
@@ -111,7 +111,7 @@ }
} encoded }) - .reduce(|| G::zero(), |a, b| a + &b); + .reduce(G::zero, |a, b| a + &b); end_timer!(eval_time); Ok(result)
M
r1cs-std/src/bits/boolean.rs
→
r1cs-std/src/bits/boolean.rs
@@ -586,7 +586,7 @@ if b {
// This is part of a run of ones. current_run.push(a.clone()); } else { - if current_run.len() > 0 { + if !current_run.is_empty() { // This is the start of a run of zeros, but we need // to k-ary AND against `last_run` first.
M
r1cs-std/src/fields/mod.rs
→
r1cs-std/src/fields/mod.rs
@@ -405,7 +405,7 @@ );
assert_eq!(a_inv.get_value().unwrap(), a_native.inverse().unwrap()); // a * a * a = a^3 let bits = BitIterator::new([0x3]) - .map(|bit| Boolean::constant(bit)) + .map(Boolean::constant) .collect::<Vec<_>>(); assert_eq!( a_native * &(a_native * &a_native),
M
r1cs-std/src/lib.rs
→
r1cs-std/src/lib.rs
@@ -71,9 +71,6 @@ }
impl<T> Assignment<T> for Option<T> { fn get(self) -> Result<T, r1cs_core::SynthesisError> { - match self { - Some(v) => Ok(v), - None => Err(r1cs_core::SynthesisError::AssignmentMissing), - } + self.ok_or_else(|| { r1cs_core::SynthesisError::AssignmentMissing }) } }