Skip to content

Commit a455c91

Browse files
committed
clippy: get rid of &Pattern(ref field) reference stuff
When matching on a reference, rustc will automatically deal with layers of dereferencing.
1 parent 1351c20 commit a455c91

File tree

4 files changed

+38
-38
lines changed

4 files changed

+38
-38
lines changed

src/miniscript/iter.rs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -63,30 +63,30 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> Miniscript<Pk, Ctx> {
6363
/// Returns child node with given index, if any
6464
pub fn get_nth_child(&self, n: usize) -> Option<&Miniscript<Pk, Ctx>> {
6565
match (n, &self.node) {
66-
(0, &Terminal::Alt(ref node))
67-
| (0, &Terminal::Swap(ref node))
68-
| (0, &Terminal::Check(ref node))
69-
| (0, &Terminal::DupIf(ref node))
70-
| (0, &Terminal::Verify(ref node))
71-
| (0, &Terminal::NonZero(ref node))
72-
| (0, &Terminal::ZeroNotEqual(ref node))
73-
| (0, &Terminal::AndV(ref node, _))
74-
| (0, &Terminal::AndB(ref node, _))
75-
| (0, &Terminal::OrB(ref node, _))
76-
| (0, &Terminal::OrD(ref node, _))
77-
| (0, &Terminal::OrC(ref node, _))
78-
| (0, &Terminal::OrI(ref node, _))
79-
| (1, &Terminal::AndV(_, ref node))
80-
| (1, &Terminal::AndB(_, ref node))
81-
| (1, &Terminal::OrB(_, ref node))
82-
| (1, &Terminal::OrD(_, ref node))
83-
| (1, &Terminal::OrC(_, ref node))
84-
| (1, &Terminal::OrI(_, ref node))
85-
| (0, &Terminal::AndOr(ref node, _, _))
86-
| (1, &Terminal::AndOr(_, ref node, _))
87-
| (2, &Terminal::AndOr(_, _, ref node)) => Some(node),
88-
89-
(n, &Terminal::Thresh(_, ref node_vec)) => node_vec.get(n).map(|x| &**x),
66+
(0, Terminal::Alt(node))
67+
| (0, Terminal::Swap(node))
68+
| (0, Terminal::Check(node))
69+
| (0, Terminal::DupIf(node))
70+
| (0, Terminal::Verify(node))
71+
| (0, Terminal::NonZero(node))
72+
| (0, Terminal::ZeroNotEqual(node))
73+
| (0, Terminal::AndV(node, _))
74+
| (0, Terminal::AndB(node, _))
75+
| (0, Terminal::OrB(node, _))
76+
| (0, Terminal::OrD(node, _))
77+
| (0, Terminal::OrC(node, _))
78+
| (0, Terminal::OrI(node, _))
79+
| (1, Terminal::AndV(_, node))
80+
| (1, Terminal::AndB(_, node))
81+
| (1, Terminal::OrB(_, node))
82+
| (1, Terminal::OrD(_, node))
83+
| (1, Terminal::OrC(_, node))
84+
| (1, Terminal::OrI(_, node))
85+
| (0, Terminal::AndOr(node, _, _))
86+
| (1, Terminal::AndOr(_, node, _))
87+
| (2, Terminal::AndOr(_, _, node)) => Some(node),
88+
89+
(n, Terminal::Thresh(_, node_vec)) => node_vec.get(n).map(|x| &**x),
9090

9191
_ => None,
9292
}

src/miniscript/satisfy.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -537,17 +537,17 @@ impl PartialOrd for Witness {
537537
impl Ord for Witness {
538538
fn cmp(&self, other: &Self) -> cmp::Ordering {
539539
match (self, other) {
540-
(&Witness::Stack(ref v1), &Witness::Stack(ref v2)) => {
540+
(Witness::Stack(v1), Witness::Stack(v2)) => {
541541
let w1 = witness_size(v1);
542542
let w2 = witness_size(v2);
543543
w1.cmp(&w2)
544544
}
545-
(&Witness::Stack(_), _) => cmp::Ordering::Less,
546-
(_, &Witness::Stack(_)) => cmp::Ordering::Greater,
547-
(&Witness::Impossible, &Witness::Unavailable) => cmp::Ordering::Less,
548-
(&Witness::Unavailable, &Witness::Impossible) => cmp::Ordering::Greater,
549-
(&Witness::Impossible, &Witness::Impossible) => cmp::Ordering::Equal,
550-
(&Witness::Unavailable, &Witness::Unavailable) => cmp::Ordering::Equal,
545+
(Witness::Stack(_), _) => cmp::Ordering::Less,
546+
(_, Witness::Stack(_)) => cmp::Ordering::Greater,
547+
(Witness::Impossible, Witness::Unavailable) => cmp::Ordering::Less,
548+
(Witness::Unavailable, Witness::Impossible) => cmp::Ordering::Greater,
549+
(Witness::Impossible, Witness::Impossible) => cmp::Ordering::Equal,
550+
(Witness::Unavailable, Witness::Unavailable) => cmp::Ordering::Equal,
551551
}
552552
}
553553
}
@@ -751,7 +751,7 @@ impl Satisfaction {
751751
// This can only be the case when we have PkH without the corresponding
752752
// Pubkey.
753753
(_, &Witness::Unavailable) | (_, &Witness::Impossible) => i64::MIN,
754-
(&Witness::Stack(ref s), &Witness::Stack(ref d)) => {
754+
(Witness::Stack(s), Witness::Stack(d)) => {
755755
witness_size(s) as i64 - witness_size(d) as i64
756756
}
757757
};
@@ -869,7 +869,7 @@ impl Satisfaction {
869869
(&Witness::Unavailable, _) | (&Witness::Impossible, _) => i64::MAX,
870870
// This is only possible when one of the branches has PkH
871871
(_, &Witness::Unavailable) | (_, &Witness::Impossible) => i64::MIN,
872-
(&Witness::Stack(ref s), &Witness::Stack(ref d)) => {
872+
(Witness::Stack(s), Witness::Stack(d)) => {
873873
witness_size(s) as i64 - witness_size(d) as i64
874874
}
875875
}

src/policy/concrete.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
764764
)),
765765
Policy::Or(ref subs) => Ok(Policy::Or(
766766
subs.iter()
767-
.map(|&(ref prob, ref sub)| Ok((*prob, sub._translate_pk(t)?)))
767+
.map(|(prob, sub)| Ok((*prob, sub._translate_pk(t)?)))
768768
.collect::<Result<Vec<(usize, Policy<Q>)>, E>>()?,
769769
)),
770770
}
@@ -896,7 +896,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
896896
Policy::Or(ref subs) => {
897897
let iter = subs
898898
.iter()
899-
.map(|&(ref _p, ref sub)| sub.check_timelocks_helper());
899+
.map(|(_p, sub)| sub.check_timelocks_helper());
900900
TimelockInfo::combine_threshold(1, iter)
901901
}
902902
}
@@ -925,7 +925,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
925925
Err(PolicyError::NonBinaryArgOr)
926926
} else {
927927
subs.iter()
928-
.map(|&(ref _prob, ref sub)| sub.is_valid())
928+
.map(|(_prob, sub)| sub.is_valid())
929929
.collect::<Result<Vec<()>, PolicyError>>()?;
930930
Ok(())
931931
}
@@ -1002,7 +1002,7 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
10021002
Policy::Or(ref subs) => {
10031003
let (all_safe, atleast_one_safe, all_non_mall) = subs
10041004
.iter()
1005-
.map(|&(_, ref sub)| sub.is_safe_nonmalleable())
1005+
.map(|(_, sub)| sub.is_safe_nonmalleable())
10061006
.fold((true, false, true), |acc, x| {
10071007
(acc.0 && x.0, acc.1 || x.0, acc.2 && x.1)
10081008
});

src/policy/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ impl<Pk: MiniscriptKey> Liftable<Pk> for Concrete<Pk> {
204204
}
205205
Concrete::Or(ref subs) => {
206206
let semantic_subs: Result<_, Error> =
207-
subs.iter().map(|&(ref _p, ref sub)| sub.lift()).collect();
207+
subs.iter().map(|(_p, sub)| sub.lift()).collect();
208208
Semantic::Threshold(1, semantic_subs?)
209209
}
210210
Concrete::Threshold(k, ref subs) => {

0 commit comments

Comments
 (0)