diff --git a/halo2_gadgets/src/sha256/table16/message_schedule.rs b/halo2_gadgets/src/sha256/table16/message_schedule.rs index 4ac644a1..3d769bb1 100644 --- a/halo2_gadgets/src/sha256/table16/message_schedule.rs +++ b/halo2_gadgets/src/sha256/table16/message_schedule.rs @@ -435,7 +435,7 @@ mod tests { // Run message_scheduler to get W_[0..64] let (w, _) = config.message_schedule.process(&mut layouter, inputs)?; for (word, test_word) in w.iter().zip(MSG_SCHEDULE_TEST_OUTPUT.iter()) { - let word: u32 = lebs2ip(&word.value().unwrap()) as u32; + let word: u32 = lebs2ip(word.value().unwrap()) as u32; assert_eq!(word, *test_word); } Ok(()) diff --git a/halo2_gadgets/src/sha256/table16/util.rs b/halo2_gadgets/src/sha256/table16/util.rs index 5e609b25..8a1ba9df 100644 --- a/halo2_gadgets/src/sha256/table16/util.rs +++ b/halo2_gadgets/src/sha256/table16/util.rs @@ -17,10 +17,10 @@ pub fn i2lebsp(int: u64) -> [bool; NUM_BITS] { fn gen_const_array_with_default( default_value: Output, - mut closure: impl FnMut(usize) -> Output, + closure: impl FnMut(usize) -> Output, ) -> [Output; LEN] { let mut ret: [Output; LEN] = [default_value; LEN]; - for (bit, val) in ret.iter_mut().zip((0..LEN).map(|idx| closure(idx))) { + for (bit, val) in ret.iter_mut().zip((0..LEN).map(closure)) { *bit = val; } ret diff --git a/halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs b/halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs index 7f98da5c..e323ff02 100644 --- a/halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs +++ b/halo2_gadgets/src/sinsemilla/chip/hash_to_point.rs @@ -132,16 +132,14 @@ where // Get message as a bitstring. let bitstring: Vec = message .iter() - .map(|piece: &MessagePiece| { + .flat_map(|piece: &MessagePiece| { piece .field_elem() .unwrap() .to_le_bits() .into_iter() .take(K * piece.num_words()) - .collect::>() }) - .flatten() .collect(); let hasher_S = pallas::Point::hash_to_curve(S_PERSONALIZATION); @@ -251,7 +249,7 @@ where let words: Option> = bitstring.map(|bitstring| { bitstring .chunks_exact(sinsemilla::K) - .map(|word| lebs2ip_k(word)) + .map(lebs2ip_k) .collect() }); diff --git a/halo2_gadgets/src/utilities.rs b/halo2_gadgets/src/utilities.rs index dfed7457..98260874 100644 --- a/halo2_gadgets/src/utilities.rs +++ b/halo2_gadgets/src/utilities.rs @@ -167,10 +167,10 @@ pub fn i2lebsp(int: u64) -> [bool; NUM_BITS] { /// Takes in an FnMut closure and returns a constant-length array with elements of /// type `Output`. fn gen_const_array( - mut closure: impl FnMut(usize) -> Output, + closure: impl FnMut(usize) -> Output, ) -> [Output; LEN] { let mut ret: [Output; LEN] = [Default::default(); LEN]; - for (bit, val) in ret.iter_mut().zip((0..LEN).map(|idx| closure(idx))) { + for (bit, val) in ret.iter_mut().zip((0..LEN).map(closure)) { *bit = val; } ret diff --git a/halo2_proofs/examples/cost-model.rs b/halo2_proofs/examples/cost-model.rs index b77fe7b5..158c8c5b 100644 --- a/halo2_proofs/examples/cost-model.rs +++ b/halo2_proofs/examples/cost-model.rs @@ -210,8 +210,8 @@ impl From for Circuit { .chain(opts.instance.iter()) .chain(opts.fixed.iter()) .cloned() - .chain(opts.lookup.iter().map(|l| l.queries()).flatten()) - .chain(opts.permutation.iter().map(|p| p.queries()).flatten()) + .chain(opts.lookup.iter().flat_map(|l| l.queries())) + .chain(opts.permutation.iter().flat_map(|p| p.queries())) .chain(iter::repeat("0".parse().unwrap()).take(max_deg - 1)) .collect();