Use built-in iteration functions more

This commit is contained in:
François Garillot
2019-12-02 07:28:49 -08:00
committed by Pratyush Mishra
parent c42c7dd98a
commit 53a51eb4dc
5 changed files with 6 additions and 9 deletions

View File

@@ -586,7 +586,7 @@ impl Boolean {
// 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.

View File

@@ -405,7 +405,7 @@ mod test {
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),

View File

@@ -71,9 +71,6 @@ pub trait Assignment<T> {
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 })
}
}