Use iter().flatten().any() instead of if let Some

Clippy emits:

  warning: unnecessary `if let` since only the `Some` variant of the
  iterator element is used

Use combinator chain `iter().flatten().any()` to check for an node with
hidden nodes.
This commit is contained in:
Tobin C. Harding 2022-05-25 13:36:51 +10:00
parent 4b28a1bb97
commit 62ccc9102c
1 changed files with 1 additions and 8 deletions

View File

@ -442,14 +442,7 @@ impl TaprootBuilder {
/// Checks if the builder has hidden nodes. /// Checks if the builder has hidden nodes.
pub fn has_hidden_nodes(&self) -> bool { pub fn has_hidden_nodes(&self) -> bool {
for node in &self.branch { self.branch.iter().flatten().any(|node| node.has_hidden_nodes)
if let Some(node) = node {
if node.has_hidden_nodes {
return true
}
}
}
false
} }
/// Creates a [`TaprootSpendInfo`] with the given internal key. /// Creates a [`TaprootSpendInfo`] with the given internal key.