Skip to content

Commit 0f95f37

Browse files
kantaiJiloc
andauthored
refactor: match on single element slice
Co-authored-by: Francesco <[email protected]>
1 parent 73980de commit 0f95f37

File tree

1 file changed

+4
-5
lines changed
  • stackslib/src/chainstate/stacks/index

1 file changed

+4
-5
lines changed

stackslib/src/chainstate/stacks/index/trie.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -854,11 +854,10 @@ impl Trie {
854854
children_root_hash: &TrieHash,
855855
) -> Result<TrieHash, Error> {
856856
let hashes = Trie::get_trie_root_ancestor_hashes_bytes(storage, children_root_hash)?;
857-
if hashes.len() == 1 {
858-
#[allow(clippy::indexing_slicing)]
859-
Ok(hashes[0])
860-
} else {
861-
Ok(TrieHash::from_data_array(hashes.as_slice()))
857+
let hashes = Trie::get_trie_root_ancestor_hashes_bytes(storage, children_root_hash)?;
858+
match hashes.as_slice() {
859+
[single_hash] => Ok(*single_hash),
860+
multiple_hashes => Ok(TrieHash::from_data_array(multiple_hashes)),
862861
}
863862
}
864863

0 commit comments

Comments
 (0)