From e84ca292d9ebbe2aeb69dca2238bc009cc0468a2 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Fri, 25 Aug 2023 12:08:56 +1000 Subject: [PATCH 1/2] Clear incorrect implementation of clone warning Clippy emits: error: incorrect implementation of `clone` on a `Copy` type As suggested use `*self` instead of each individual field. --- hashes/src/sha256t.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hashes/src/sha256t.rs b/hashes/src/sha256t.rs index 6b94dfc8..6b4847a9 100644 --- a/hashes/src/sha256t.rs +++ b/hashes/src/sha256t.rs @@ -39,7 +39,7 @@ impl Hash { impl Copy for Hash {} impl Clone for Hash { - fn clone(&self) -> Self { Hash(self.0, self.1) } + fn clone(&self) -> Self { *self } } impl PartialEq for Hash { fn eq(&self, other: &Hash) -> bool { self.0 == other.0 } From 724be17394cda74d5c317abcc03fe234cda57577 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Fri, 25 Aug 2023 12:30:04 +1000 Subject: [PATCH 2/2] Remove useless usage of vec! macro Clippy emits a bunch of warnings of form: warning: useless use of `vec!` As suggested, remove the vec and just use an array. --- bitcoin/src/amount.rs | 5 ++--- bitcoin/src/bip158.rs | 2 +- bitcoin/src/merkle_tree/block.rs | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/bitcoin/src/amount.rs b/bitcoin/src/amount.rs index aa008b44..0e9135b8 100644 --- a/bitcoin/src/amount.rs +++ b/bitcoin/src/amount.rs @@ -2361,8 +2361,7 @@ mod tests { #[test] fn disallow_confusing_forms() { - let confusing = - vec!["Msat", "Msats", "MSAT", "MSATS", "MSat", "MSats", "MBTC", "Mbtc", "PBTC"]; + let confusing = ["Msat", "Msats", "MSAT", "MSATS", "MSat", "MSats", "MBTC", "Mbtc", "PBTC"]; for denom in confusing.iter() { match Denomination::from_str(denom) { Ok(_) => panic!("from_str should error for {}", denom), @@ -2375,7 +2374,7 @@ mod tests { #[test] fn disallow_unknown_denomination() { // Non-exhaustive list of unknown forms. - let unknown = vec!["NBTC", "UBTC", "ABC", "abc", "cBtC", "Sat", "Sats"]; + let unknown = ["NBTC", "UBTC", "ABC", "abc", "cBtC", "Sat", "Sats"]; for denom in unknown.iter() { match Denomination::from_str(denom) { Ok(_) => panic!("from_str should error for {}", denom), diff --git a/bitcoin/src/bip158.rs b/bitcoin/src/bip158.rs index 603fae65..97a4b222 100644 --- a/bitcoin/src/bip158.rs +++ b/bitcoin/src/bip158.rs @@ -616,7 +616,7 @@ mod test { .unwrap()); for script in txmap.values() { - let query = vec![script]; + let query = [script]; if !script.is_empty() { assert!(filter .match_any(block_hash, &mut query.iter().map(|s| s.as_bytes())) diff --git a/bitcoin/src/merkle_tree/block.rs b/bitcoin/src/merkle_tree/block.rs index 076e55dc..95d51bdd 100644 --- a/bitcoin/src/merkle_tree/block.rs +++ b/bitcoin/src/merkle_tree/block.rs @@ -700,7 +700,7 @@ mod tests { let txid1 = txids[0]; let txid2 = txids[1]; - let txids = vec![txid1, txid2]; + let txids = [txid1, txid2]; let merkle_block = MerkleBlock::from_block_with_predicate(&block, |t| txids.contains(t));