Fix some clippy lints

This commit is contained in:
Jack Grigg 2022-04-27 12:22:45 +00:00
parent e3f1bf68db
commit f4675997bc
5 changed files with 9 additions and 11 deletions

View File

@ -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(())

View File

@ -17,10 +17,10 @@ pub fn i2lebsp<const NUM_BITS: usize>(int: u64) -> [bool; NUM_BITS] {
fn gen_const_array_with_default<Output: Copy, const LEN: usize>(
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

View File

@ -132,16 +132,14 @@ where
// Get message as a bitstring.
let bitstring: Vec<bool> = message
.iter()
.map(|piece: &MessagePiece<pallas::Base, K>| {
.flat_map(|piece: &MessagePiece<pallas::Base, K>| {
piece
.field_elem()
.unwrap()
.to_le_bits()
.into_iter()
.take(K * piece.num_words())
.collect::<Vec<_>>()
})
.flatten()
.collect();
let hasher_S = pallas::Point::hash_to_curve(S_PERSONALIZATION);
@ -251,7 +249,7 @@ where
let words: Option<Vec<u32>> = bitstring.map(|bitstring| {
bitstring
.chunks_exact(sinsemilla::K)
.map(|word| lebs2ip_k(word))
.map(lebs2ip_k)
.collect()
});

View File

@ -167,10 +167,10 @@ pub fn i2lebsp<const NUM_BITS: usize>(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<Output: Copy + Default, const LEN: usize>(
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

View File

@ -210,8 +210,8 @@ impl From<CostOptions> 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();