Skip to content

Commit 3e12a21

Browse files
committed
Remove the redundant calls to clone on Copy type
Clippy emits a bunch of warnings of type: warning: using `clone` on type <elided> which implements the `Copy` trait As suggested, remove the redundant calls to clone.
1 parent 1e476ab commit 3e12a21

File tree

5 files changed

+56
-57
lines changed

5 files changed

+56
-57
lines changed

src/miniscript/types/extra_props.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,47 +1046,47 @@ impl Property for ExtData {
10461046
Terminal::Hash256(..) => Ok(Self::from_hash256()),
10471047
Terminal::Ripemd160(..) => Ok(Self::from_ripemd160()),
10481048
Terminal::Hash160(..) => Ok(Self::from_hash160()),
1049-
Terminal::Alt(ref sub) => wrap_err(Self::cast_alt(sub.ext.clone())),
1050-
Terminal::Swap(ref sub) => wrap_err(Self::cast_swap(sub.ext.clone())),
1051-
Terminal::Check(ref sub) => wrap_err(Self::cast_check(sub.ext.clone())),
1052-
Terminal::DupIf(ref sub) => wrap_err(Self::cast_dupif(sub.ext.clone())),
1053-
Terminal::Verify(ref sub) => wrap_err(Self::cast_verify(sub.ext.clone())),
1054-
Terminal::NonZero(ref sub) => wrap_err(Self::cast_nonzero(sub.ext.clone())),
1055-
Terminal::ZeroNotEqual(ref sub) => wrap_err(Self::cast_zeronotequal(sub.ext.clone())),
1049+
Terminal::Alt(ref sub) => wrap_err(Self::cast_alt(sub.ext)),
1050+
Terminal::Swap(ref sub) => wrap_err(Self::cast_swap(sub.ext)),
1051+
Terminal::Check(ref sub) => wrap_err(Self::cast_check(sub.ext)),
1052+
Terminal::DupIf(ref sub) => wrap_err(Self::cast_dupif(sub.ext)),
1053+
Terminal::Verify(ref sub) => wrap_err(Self::cast_verify(sub.ext)),
1054+
Terminal::NonZero(ref sub) => wrap_err(Self::cast_nonzero(sub.ext)),
1055+
Terminal::ZeroNotEqual(ref sub) => wrap_err(Self::cast_zeronotequal(sub.ext)),
10561056
Terminal::AndB(ref l, ref r) => {
1057-
let ltype = l.ext.clone();
1058-
let rtype = r.ext.clone();
1057+
let ltype = l.ext;
1058+
let rtype = r.ext;
10591059
wrap_err(Self::and_b(ltype, rtype))
10601060
}
10611061
Terminal::AndV(ref l, ref r) => {
1062-
let ltype = l.ext.clone();
1063-
let rtype = r.ext.clone();
1062+
let ltype = l.ext;
1063+
let rtype = r.ext;
10641064
wrap_err(Self::and_v(ltype, rtype))
10651065
}
10661066
Terminal::OrB(ref l, ref r) => {
1067-
let ltype = l.ext.clone();
1068-
let rtype = r.ext.clone();
1067+
let ltype = l.ext;
1068+
let rtype = r.ext;
10691069
wrap_err(Self::or_b(ltype, rtype))
10701070
}
10711071
Terminal::OrD(ref l, ref r) => {
1072-
let ltype = l.ext.clone();
1073-
let rtype = r.ext.clone();
1072+
let ltype = l.ext;
1073+
let rtype = r.ext;
10741074
wrap_err(Self::or_d(ltype, rtype))
10751075
}
10761076
Terminal::OrC(ref l, ref r) => {
1077-
let ltype = l.ext.clone();
1078-
let rtype = r.ext.clone();
1077+
let ltype = l.ext;
1078+
let rtype = r.ext;
10791079
wrap_err(Self::or_c(ltype, rtype))
10801080
}
10811081
Terminal::OrI(ref l, ref r) => {
1082-
let ltype = l.ext.clone();
1083-
let rtype = r.ext.clone();
1082+
let ltype = l.ext;
1083+
let rtype = r.ext;
10841084
wrap_err(Self::or_i(ltype, rtype))
10851085
}
10861086
Terminal::AndOr(ref a, ref b, ref c) => {
1087-
let atype = a.ext.clone();
1088-
let btype = b.ext.clone();
1089-
let ctype = c.ext.clone();
1087+
let atype = a.ext;
1088+
let btype = b.ext;
1089+
let ctype = c.ext;
10901090
wrap_err(Self::and_or(atype, btype, ctype))
10911091
}
10921092
Terminal::Thresh(k, ref subs) => {
@@ -1103,7 +1103,7 @@ impl Property for ExtData {
11031103
});
11041104
}
11051105

1106-
let res = Self::threshold(k, subs.len(), |n| Ok(subs[n].ext.clone()));
1106+
let res = Self::threshold(k, subs.len(), |n| Ok(subs[n].ext));
11071107

11081108
res.map_err(|kind| Error {
11091109
fragment: fragment.clone(),

src/miniscript/types/mod.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -840,47 +840,47 @@ impl Property for Type {
840840
Terminal::Hash256(..) => Ok(Self::from_hash256()),
841841
Terminal::Ripemd160(..) => Ok(Self::from_ripemd160()),
842842
Terminal::Hash160(..) => Ok(Self::from_hash160()),
843-
Terminal::Alt(ref sub) => wrap_err(Self::cast_alt(sub.ty.clone())),
844-
Terminal::Swap(ref sub) => wrap_err(Self::cast_swap(sub.ty.clone())),
845-
Terminal::Check(ref sub) => wrap_err(Self::cast_check(sub.ty.clone())),
846-
Terminal::DupIf(ref sub) => wrap_err(Self::cast_dupif(sub.ty.clone())),
847-
Terminal::Verify(ref sub) => wrap_err(Self::cast_verify(sub.ty.clone())),
848-
Terminal::NonZero(ref sub) => wrap_err(Self::cast_nonzero(sub.ty.clone())),
849-
Terminal::ZeroNotEqual(ref sub) => wrap_err(Self::cast_zeronotequal(sub.ty.clone())),
843+
Terminal::Alt(ref sub) => wrap_err(Self::cast_alt(sub.ty)),
844+
Terminal::Swap(ref sub) => wrap_err(Self::cast_swap(sub.ty)),
845+
Terminal::Check(ref sub) => wrap_err(Self::cast_check(sub.ty)),
846+
Terminal::DupIf(ref sub) => wrap_err(Self::cast_dupif(sub.ty)),
847+
Terminal::Verify(ref sub) => wrap_err(Self::cast_verify(sub.ty)),
848+
Terminal::NonZero(ref sub) => wrap_err(Self::cast_nonzero(sub.ty)),
849+
Terminal::ZeroNotEqual(ref sub) => wrap_err(Self::cast_zeronotequal(sub.ty)),
850850
Terminal::AndB(ref l, ref r) => {
851-
let ltype = l.ty.clone();
852-
let rtype = r.ty.clone();
851+
let ltype = l.ty;
852+
let rtype = r.ty;
853853
wrap_err(Self::and_b(ltype, rtype))
854854
}
855855
Terminal::AndV(ref l, ref r) => {
856-
let ltype = l.ty.clone();
857-
let rtype = r.ty.clone();
856+
let ltype = l.ty;
857+
let rtype = r.ty;
858858
wrap_err(Self::and_v(ltype, rtype))
859859
}
860860
Terminal::OrB(ref l, ref r) => {
861-
let ltype = l.ty.clone();
862-
let rtype = r.ty.clone();
861+
let ltype = l.ty;
862+
let rtype = r.ty;
863863
wrap_err(Self::or_b(ltype, rtype))
864864
}
865865
Terminal::OrD(ref l, ref r) => {
866-
let ltype = l.ty.clone();
867-
let rtype = r.ty.clone();
866+
let ltype = l.ty;
867+
let rtype = r.ty;
868868
wrap_err(Self::or_d(ltype, rtype))
869869
}
870870
Terminal::OrC(ref l, ref r) => {
871-
let ltype = l.ty.clone();
872-
let rtype = r.ty.clone();
871+
let ltype = l.ty;
872+
let rtype = r.ty;
873873
wrap_err(Self::or_c(ltype, rtype))
874874
}
875875
Terminal::OrI(ref l, ref r) => {
876-
let ltype = l.ty.clone();
877-
let rtype = r.ty.clone();
876+
let ltype = l.ty;
877+
let rtype = r.ty;
878878
wrap_err(Self::or_i(ltype, rtype))
879879
}
880880
Terminal::AndOr(ref a, ref b, ref c) => {
881-
let atype = a.ty.clone();
882-
let btype = b.ty.clone();
883-
let ctype = c.ty.clone();
881+
let atype = a.ty;
882+
let btype = b.ty;
883+
let ctype = c.ty;
884884
wrap_err(Self::and_or(atype, btype, ctype))
885885
}
886886
Terminal::Thresh(k, ref subs) => {
@@ -897,7 +897,7 @@ impl Property for Type {
897897
});
898898
}
899899

900-
let res = Self::threshold(k, subs.len(), |n| Ok(subs[n].ty.clone()));
900+
let res = Self::threshold(k, subs.len(), |n| Ok(subs[n].ty));
901901

902902
res.map_err(|kind| Error {
903903
fragment: fragment.clone(),

src/policy/concrete.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,10 +202,10 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
202202
Policy::Unsatisfiable => Ok(Policy::Unsatisfiable),
203203
Policy::Trivial => Ok(Policy::Trivial),
204204
Policy::Key(ref pk) => translatefpk(pk).map(Policy::Key),
205-
Policy::Sha256(ref h) => Ok(Policy::Sha256(h.clone())),
206-
Policy::Hash256(ref h) => Ok(Policy::Hash256(h.clone())),
207-
Policy::Ripemd160(ref h) => Ok(Policy::Ripemd160(h.clone())),
208-
Policy::Hash160(ref h) => Ok(Policy::Hash160(h.clone())),
205+
Policy::Sha256(ref h) => Ok(Policy::Sha256(*h)),
206+
Policy::Hash256(ref h) => Ok(Policy::Hash256(*h)),
207+
Policy::Ripemd160(ref h) => Ok(Policy::Ripemd160(*h)),
208+
Policy::Hash160(ref h) => Ok(Policy::Hash160(*h)),
209209
Policy::After(n) => Ok(Policy::After(n)),
210210
Policy::Older(n) => Ok(Policy::Older(n)),
211211
Policy::Threshold(k, ref subs) => {

src/policy/semantic.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,10 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
116116
Policy::Unsatisfiable => Ok(Policy::Unsatisfiable),
117117
Policy::Trivial => Ok(Policy::Trivial),
118118
Policy::KeyHash(ref pkh) => translatefpkh(pkh).map(Policy::KeyHash),
119-
Policy::Sha256(ref h) => Ok(Policy::Sha256(h.clone())),
120-
Policy::Hash256(ref h) => Ok(Policy::Hash256(h.clone())),
121-
Policy::Ripemd160(ref h) => Ok(Policy::Ripemd160(h.clone())),
122-
Policy::Hash160(ref h) => Ok(Policy::Hash160(h.clone())),
119+
Policy::Sha256(ref h) => Ok(Policy::Sha256(*h)),
120+
Policy::Hash256(ref h) => Ok(Policy::Hash256(*h)),
121+
Policy::Ripemd160(ref h) => Ok(Policy::Ripemd160(*h)),
122+
Policy::Hash160(ref h) => Ok(Policy::Hash160(*h)),
123123
Policy::After(n) => Ok(Policy::After(n)),
124124
Policy::Older(n) => Ok(Policy::Older(n)),
125125
Policy::Threshold(k, ref subs) => {

src/psbt/mod.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -959,10 +959,9 @@ fn update_input_with_descriptor_helper(
959959
(pk.to_x_only_pubkey(), xpk)
960960
}
961961
(PkPkh::HashedPubkey(hash), PkPkh::HashedPubkey(xpk)) => (
962-
hash_lookup
962+
*hash_lookup
963963
.get(&hash)
964-
.expect("translate_pk inserted an entry for every hash")
965-
.clone(),
964+
.expect("translate_pk inserted an entry for every hash"),
966965
xpk,
967966
),
968967
_ => unreachable!("the iterators work in the same order"),

0 commit comments

Comments
 (0)