Skip to content

Commit

Permalink
Clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
Nashtare committed Jan 22, 2024
1 parent f317e4b commit 5a4c754
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 20 deletions.
10 changes: 4 additions & 6 deletions src/nibbles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -607,13 +607,11 @@ impl Nibbles {
let hex_string_raw = hex_encode_f(&byte_buf[(64 - count_bytes)..64]);
let hex_char_iter_raw = hex_string_raw.chars();

let hex_char_iter = match is_even(self.count) {
false => hex_char_iter_raw.skip(1),
true => hex_char_iter_raw.skip(0),
};

let mut hex_string = String::from("0x");
hex_string.extend(hex_char_iter);
match is_even(self.count) {
false => hex_string.extend(hex_char_iter_raw.skip(1)),
true => hex_string.extend(hex_char_iter_raw),
};

hex_string
}
Expand Down
2 changes: 1 addition & 1 deletion src/partial_trie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ where
V: Into<ValOrHash>,
{
let mut root = N::new(Node::Empty);
root.extend(nodes.into_iter());
root.extend(nodes);

root
}
15 changes: 6 additions & 9 deletions src/trie_hashing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,15 +383,12 @@ mod tests {

#[test]
fn replacing_branch_of_leaves_with_hash_nodes_produced_same_hash() {
let mut trie = HashedPartialTrie::from_iter(
[
large_entry(0x1),
large_entry(0x2),
large_entry(0x3),
large_entry(0x4),
]
.into_iter(),
);
let mut trie = HashedPartialTrie::from_iter([
large_entry(0x1),
large_entry(0x2),
large_entry(0x3),
large_entry(0x4),
]);

let orig_hash = trie.hash();

Expand Down
6 changes: 3 additions & 3 deletions src/trie_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ impl<N: PartialTrie> PartialTrieIter<N> {
}
Node::Extension { nibbles, child } => {
if TrieNodeType::from(child) != TrieNodeType::Hash {
self.trie_stack
.push(IterStackEntry::Extension(nibbles.count));
self.trie_stack
.push(IterStackEntry::Extension(nibbles.count));
}

curr_key = curr_key.merge_nibbles(nibbles);
Expand Down Expand Up @@ -857,7 +857,7 @@ mod tests {
let mut entries = [entry(0x1234), entry(0x1234)];
entries[1].1 = vec![100];

let trie = StandardTrie::from_iter(entries.into_iter());
let trie = StandardTrie::from_iter(entries);
assert_eq!(trie.get(0x1234), Some([100].as_slice()));
}

Expand Down
2 changes: 1 addition & 1 deletion src/trie_subsets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ mod tests {
fn multi_node_trie_returns_proper_subset() {
let trie = create_trie_with_large_entry_nodes(&[0x1234, 0x56, 0x12345_u64]);

let trie_subset = create_trie_subset(&trie, vec![0x1234, 0x56].into_iter()).unwrap();
let trie_subset = create_trie_subset(&trie, vec![0x1234, 0x56]).unwrap();
let leaf_keys = get_all_nibbles_of_leaf_nodes_in_trie(&trie_subset);

assert!(leaf_keys.contains(&(Nibbles::from(0x1234))));
Expand Down

0 comments on commit 5a4c754

Please sign in to comment.