From 27649ba182b5f55ffff2dc3261c66fc8bedc6785 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Wed, 25 May 2022 13:40:13 +1000 Subject: [PATCH] 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. --- src/util/ecdsa.rs | 2 +- src/util/taproot.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/ecdsa.rs b/src/util/ecdsa.rs index 185b22f6..93adf490 100644 --- a/src/util/ecdsa.rs +++ b/src/util/ecdsa.rs @@ -58,7 +58,7 @@ impl EcdsaSig { pub fn to_vec(&self) -> Vec { // 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() } diff --git a/src/util/taproot.rs b/src/util/taproot.rs index 2bd2a24b..1459788f 100644 --- a/src/util/taproot.rs +++ b/src/util/taproot.rs @@ -675,7 +675,7 @@ impl TaprootMerkleBranch { /// Serializes `self` as bytes. pub fn serialize(&self) -> Vec { - self.0.iter().map(|e| e.as_inner()).flatten().map(|x| *x).collect::>() + self.0.iter().flat_map(|e| e.as_inner()).copied().collect::>() } /// Appends elements to proof.