Skip to content

Commit

Permalink
Use copied instead of map to copy
Browse files Browse the repository at this point in the history
Clippy emits:

  warning: you are using an explicit closure for copying elements

In one instance we have `map` followed by `flatten`, this can be
replaced by the `flat_map` combinator.

As suggested use `copied` combinator.
  • Loading branch information
tcharding committed May 25, 2022
1 parent 62ccc91 commit 27649ba
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/util/ecdsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ impl EcdsaSig {
pub fn to_vec(&self) -> Vec<u8> {
// TODO: add support to serialize to a writer to SerializedSig
self.sig.serialize_der()
.iter().map(|x| *x)
.iter().copied()
.chain(iter::once(self.hash_ty as u8))
.collect()
}
Expand Down
2 changes: 1 addition & 1 deletion src/util/taproot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ impl TaprootMerkleBranch {

/// Serializes `self` as bytes.
pub fn serialize(&self) -> Vec<u8> {
self.0.iter().map(|e| e.as_inner()).flatten().map(|x| *x).collect::<Vec<u8>>()
self.0.iter().flat_map(|e| e.as_inner()).copied().collect::<Vec<u8>>()
}

/// Appends elements to proof.
Expand Down

0 comments on commit 27649ba

Please sign in to comment.