Use copied instead of map to copy

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.
This commit is contained in:
Tobin C. Harding 2022-05-25 13:40:13 +10:00
parent 62ccc9102c
commit 27649ba182
2 changed files with 2 additions and 2 deletions

View File

@ -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()
}

View File

@ -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.