chore(clippy): enable if_then_some_else_none lint (#11679)

Signed-off-by: jsvisa <delweng@gmail.com>
Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
Delweng
2024-10-14 23:45:26 +08:00
committed by GitHub
parent 523bfb9c81
commit f684dd4c4c
22 changed files with 87 additions and 135 deletions

View File

@ -51,16 +51,14 @@ impl Compact for StoredSubNode {
buf.advance(key_len);
let nibbles_exists = buf.get_u8() != 0;
let nibble = if nibbles_exists { Some(buf.get_u8()) } else { None };
let nibble = nibbles_exists.then(|| buf.get_u8());
let node_exists = buf.get_u8() != 0;
let node = if node_exists {
let node = node_exists.then(|| {
let (node, rest) = BranchNodeCompact::from_compact(buf, 0);
buf = rest;
Some(node)
} else {
None
};
node
});
(Self { key, nibble, node }, buf)
}

View File

@ -49,7 +49,7 @@ impl From<StoredSubNode> for CursorSubNode {
impl From<CursorSubNode> for StoredSubNode {
fn from(value: CursorSubNode) -> Self {
let nibble = if value.nibble >= 0 { Some(value.nibble as u8) } else { None };
let nibble = (value.nibble >= 0).then_some(value.nibble as u8);
Self { key: value.key.to_vec(), nibble, node: value.node }
}
}

View File

@ -111,14 +111,13 @@ where
.accounts
.get(&hashed_address)
.ok_or(TrieWitnessError::MissingAccount(hashed_address))?;
let value = if account.is_some() || storage_multiproof.root != EMPTY_ROOT_HASH {
account_rlp.clear();
TrieAccount::from((account.unwrap_or_default(), storage_multiproof.root))
.encode(&mut account_rlp as &mut dyn BufMut);
Some(account_rlp.clone())
} else {
None
};
let value =
(account.is_some() || storage_multiproof.root != EMPTY_ROOT_HASH).then(|| {
account_rlp.clear();
TrieAccount::from((account.unwrap_or_default(), storage_multiproof.root))
.encode(&mut account_rlp as &mut dyn BufMut);
account_rlp.clone()
});
let key = Nibbles::unpack(hashed_address);
account_trie_nodes.extend(
self.target_nodes(