Skip to content

Commit da6e068

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 98d4a06 commit da6e068

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
@@ -951,47 +951,47 @@ impl Property for ExtData {
951951
Terminal::Hash256(..) => Ok(Self::from_hash256()),
952952
Terminal::Ripemd160(..) => Ok(Self::from_ripemd160()),
953953
Terminal::Hash160(..) => Ok(Self::from_hash160()),
954-
Terminal::Alt(ref sub) => wrap_err(Self::cast_alt(sub.ext.clone())),
955-
Terminal::Swap(ref sub) => wrap_err(Self::cast_swap(sub.ext.clone())),
956-
Terminal::Check(ref sub) => wrap_err(Self::cast_check(sub.ext.clone())),
957-
Terminal::DupIf(ref sub) => wrap_err(Self::cast_dupif(sub.ext.clone())),
958-
Terminal::Verify(ref sub) => wrap_err(Self::cast_verify(sub.ext.clone())),
959-
Terminal::NonZero(ref sub) => wrap_err(Self::cast_nonzero(sub.ext.clone())),
960-
Terminal::ZeroNotEqual(ref sub) => wrap_err(Self::cast_zeronotequal(sub.ext.clone())),
954+
Terminal::Alt(ref sub) => wrap_err(Self::cast_alt(sub.ext)),
955+
Terminal::Swap(ref sub) => wrap_err(Self::cast_swap(sub.ext)),
956+
Terminal::Check(ref sub) => wrap_err(Self::cast_check(sub.ext)),
957+
Terminal::DupIf(ref sub) => wrap_err(Self::cast_dupif(sub.ext)),
958+
Terminal::Verify(ref sub) => wrap_err(Self::cast_verify(sub.ext)),
959+
Terminal::NonZero(ref sub) => wrap_err(Self::cast_nonzero(sub.ext)),
960+
Terminal::ZeroNotEqual(ref sub) => wrap_err(Self::cast_zeronotequal(sub.ext)),
961961
Terminal::AndB(ref l, ref r) => {
962-
let ltype = l.ext.clone();
963-
let rtype = r.ext.clone();
962+
let ltype = l.ext;
963+
let rtype = r.ext;
964964
wrap_err(Self::and_b(ltype, rtype))
965965
}
966966
Terminal::AndV(ref l, ref r) => {
967-
let ltype = l.ext.clone();
968-
let rtype = r.ext.clone();
967+
let ltype = l.ext;
968+
let rtype = r.ext;
969969
wrap_err(Self::and_v(ltype, rtype))
970970
}
971971
Terminal::OrB(ref l, ref r) => {
972-
let ltype = l.ext.clone();
973-
let rtype = r.ext.clone();
972+
let ltype = l.ext;
973+
let rtype = r.ext;
974974
wrap_err(Self::or_b(ltype, rtype))
975975
}
976976
Terminal::OrD(ref l, ref r) => {
977-
let ltype = l.ext.clone();
978-
let rtype = r.ext.clone();
977+
let ltype = l.ext;
978+
let rtype = r.ext;
979979
wrap_err(Self::or_d(ltype, rtype))
980980
}
981981
Terminal::OrC(ref l, ref r) => {
982-
let ltype = l.ext.clone();
983-
let rtype = r.ext.clone();
982+
let ltype = l.ext;
983+
let rtype = r.ext;
984984
wrap_err(Self::or_c(ltype, rtype))
985985
}
986986
Terminal::OrI(ref l, ref r) => {
987-
let ltype = l.ext.clone();
988-
let rtype = r.ext.clone();
987+
let ltype = l.ext;
988+
let rtype = r.ext;
989989
wrap_err(Self::or_i(ltype, rtype))
990990
}
991991
Terminal::AndOr(ref a, ref b, ref c) => {
992-
let atype = a.ext.clone();
993-
let btype = b.ext.clone();
994-
let ctype = c.ext.clone();
992+
let atype = a.ext;
993+
let btype = b.ext;
994+
let ctype = c.ext;
995995
wrap_err(Self::and_or(atype, btype, ctype))
996996
}
997997
Terminal::Thresh(k, ref subs) => {
@@ -1008,7 +1008,7 @@ impl Property for ExtData {
10081008
});
10091009
}
10101010

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

10131013
res.map_err(|kind| Error {
10141014
fragment: fragment.clone(),

src/miniscript/types/mod.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -842,47 +842,47 @@ impl Property for Type {
842842
Terminal::Hash256(..) => Ok(Self::from_hash256()),
843843
Terminal::Ripemd160(..) => Ok(Self::from_ripemd160()),
844844
Terminal::Hash160(..) => Ok(Self::from_hash160()),
845-
Terminal::Alt(ref sub) => wrap_err(Self::cast_alt(sub.ty.clone())),
846-
Terminal::Swap(ref sub) => wrap_err(Self::cast_swap(sub.ty.clone())),
847-
Terminal::Check(ref sub) => wrap_err(Self::cast_check(sub.ty.clone())),
848-
Terminal::DupIf(ref sub) => wrap_err(Self::cast_dupif(sub.ty.clone())),
849-
Terminal::Verify(ref sub) => wrap_err(Self::cast_verify(sub.ty.clone())),
850-
Terminal::NonZero(ref sub) => wrap_err(Self::cast_nonzero(sub.ty.clone())),
851-
Terminal::ZeroNotEqual(ref sub) => wrap_err(Self::cast_zeronotequal(sub.ty.clone())),
845+
Terminal::Alt(ref sub) => wrap_err(Self::cast_alt(sub.ty)),
846+
Terminal::Swap(ref sub) => wrap_err(Self::cast_swap(sub.ty)),
847+
Terminal::Check(ref sub) => wrap_err(Self::cast_check(sub.ty)),
848+
Terminal::DupIf(ref sub) => wrap_err(Self::cast_dupif(sub.ty)),
849+
Terminal::Verify(ref sub) => wrap_err(Self::cast_verify(sub.ty)),
850+
Terminal::NonZero(ref sub) => wrap_err(Self::cast_nonzero(sub.ty)),
851+
Terminal::ZeroNotEqual(ref sub) => wrap_err(Self::cast_zeronotequal(sub.ty)),
852852
Terminal::AndB(ref l, ref r) => {
853-
let ltype = l.ty.clone();
854-
let rtype = r.ty.clone();
853+
let ltype = l.ty;
854+
let rtype = r.ty;
855855
wrap_err(Self::and_b(ltype, rtype))
856856
}
857857
Terminal::AndV(ref l, ref r) => {
858-
let ltype = l.ty.clone();
859-
let rtype = r.ty.clone();
858+
let ltype = l.ty;
859+
let rtype = r.ty;
860860
wrap_err(Self::and_v(ltype, rtype))
861861
}
862862
Terminal::OrB(ref l, ref r) => {
863-
let ltype = l.ty.clone();
864-
let rtype = r.ty.clone();
863+
let ltype = l.ty;
864+
let rtype = r.ty;
865865
wrap_err(Self::or_b(ltype, rtype))
866866
}
867867
Terminal::OrD(ref l, ref r) => {
868-
let ltype = l.ty.clone();
869-
let rtype = r.ty.clone();
868+
let ltype = l.ty;
869+
let rtype = r.ty;
870870
wrap_err(Self::or_d(ltype, rtype))
871871
}
872872
Terminal::OrC(ref l, ref r) => {
873-
let ltype = l.ty.clone();
874-
let rtype = r.ty.clone();
873+
let ltype = l.ty;
874+
let rtype = r.ty;
875875
wrap_err(Self::or_c(ltype, rtype))
876876
}
877877
Terminal::OrI(ref l, ref r) => {
878-
let ltype = l.ty.clone();
879-
let rtype = r.ty.clone();
878+
let ltype = l.ty;
879+
let rtype = r.ty;
880880
wrap_err(Self::or_i(ltype, rtype))
881881
}
882882
Terminal::AndOr(ref a, ref b, ref c) => {
883-
let atype = a.ty.clone();
884-
let btype = b.ty.clone();
885-
let ctype = c.ty.clone();
883+
let atype = a.ty;
884+
let btype = b.ty;
885+
let ctype = c.ty;
886886
wrap_err(Self::and_or(atype, btype, ctype))
887887
}
888888
Terminal::Thresh(k, ref subs) => {
@@ -899,7 +899,7 @@ impl Property for Type {
899899
});
900900
}
901901

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

904904
res.map_err(|kind| Error {
905905
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) => fpk(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) => fpkh(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)