Skip to content

Commit 3ac980e

Browse files
committed
fix clippy issues
1 parent ffdd0aa commit 3ac980e

4 files changed

Lines changed: 21 additions & 30 deletions

File tree

src/merkle/integrate.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -586,13 +586,11 @@ mod tests {
586586

587587
// Chain range hashes to get root
588588
let mut root: Option<Sha256Hash> = None;
589-
for level_hash in &range {
590-
if let Some(h) = level_hash {
591-
root = Some(match root {
592-
None => *h,
593-
Some(right) => hash_children(h, &right),
594-
});
595-
}
589+
for h in range.iter().flatten() {
590+
root = Some(match root {
591+
None => *h,
592+
Some(right) => hash_children(h, &right),
593+
});
596594
}
597595

598596
root.unwrap_or_else(empty_root_hash)

src/merkle/proof_test.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,11 @@ fn compute_root(leaves: &[Sha256Hash]) -> Sha256Hash {
5555
}
5656

5757
let mut root: Option<Sha256Hash> = None;
58-
for h in &range {
59-
if let Some(hash) = h {
60-
root = Some(match root {
61-
None => *hash,
62-
Some(r) => hash_children(hash, &r),
63-
});
64-
}
58+
for hash in range.iter().flatten() {
59+
root = Some(match root {
60+
None => *hash,
61+
Some(r) => hash_children(hash, &r),
62+
});
6563
}
6664
root.unwrap_or_else(empty_root_hash)
6765
}
@@ -101,8 +99,6 @@ async fn create_test_storage(leaves: &[Sha256Hash]) -> TileStorage {
10199
/// Test that proof_length matches what we generate.
102100
#[test]
103101
fn test_expected_proof_lengths() {
104-
use crate::witness::ConsistencyProof;
105-
106102
// Calculate expected proof length using the same algorithm as the verifier
107103
fn proof_length(old_size: u64, new_size: u64) -> usize {
108104
if old_size == 0 || old_size == new_size {

src/witness/litewitness_test.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,11 @@ fn compute_root(leaves: &[Sha256Hash]) -> Sha256Hash {
6262
}
6363

6464
let mut root: Option<Sha256Hash> = None;
65-
for h in &range {
66-
if let Some(hash) = h {
67-
root = Some(match root {
68-
None => *hash,
69-
Some(r) => hash_children(hash, &r),
70-
});
71-
}
65+
for hash in range.iter().flatten() {
66+
root = Some(match root {
67+
None => *hash,
68+
Some(r) => hash_children(hash, &r),
69+
});
7270
}
7371
root.unwrap_or_else(empty_root_hash)
7472
}

src/witness/proof.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ mod tests {
348348
use sigstore_merkle::hash_leaf;
349349

350350
/// Build a complete tree and return the root hash.
351+
#[allow(dead_code)]
351352
fn build_tree(leaves: &[Sha256Hash]) -> Sha256Hash {
352353
if leaves.is_empty() {
353354
return empty_root_hash();
@@ -383,13 +384,11 @@ mod tests {
383384

384385
// Compute root from range
385386
let mut root: Option<Sha256Hash> = None;
386-
for h in &range {
387-
if let Some(hash) = h {
388-
root = Some(match root {
389-
None => *hash,
390-
Some(r) => hash_children(hash, &r),
391-
});
392-
}
387+
for hash in range.iter().flatten() {
388+
root = Some(match root {
389+
None => *hash,
390+
Some(r) => hash_children(hash, &r),
391+
});
393392
}
394393
root.unwrap_or_else(empty_root_hash)
395394
}

0 commit comments

Comments
 (0)