Skip to content

Commit ad66c9c

Browse files
committed
Merge #904: Inline if statements into match arm
32ff3a0 Inline if statements into match arm (Tobin C. Harding) Pull request description: Found by the imminent upgrade to nightly (PR #903). No logic change. ACKs for top commit: apoelstra: ACK 32ff3a0; successfully ran local tests Tree-SHA512: 5a592b0559dbd19a549ede17156213f1f648a20c74c232e723d3defb4d8ace5c920f81185807df218753144c1b4d378476924a002eeb0de00db3993fc27c77fc
2 parents f42e646 + 32ff3a0 commit ad66c9c

2 files changed

Lines changed: 12 additions & 24 deletions

File tree

src/miniscript/mod.rs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -628,27 +628,19 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> ForEachKey<Pk> for Miniscript<Pk, Ct
628628
fn for_each_key<'a, F: FnMut(&'a Pk) -> bool>(&'a self, mut pred: F) -> bool {
629629
for ms in self.pre_order_iter() {
630630
match ms.node {
631-
Terminal::PkK(ref p) => {
632-
if !pred(p) {
633-
return false;
634-
}
631+
Terminal::PkK(ref p) if !pred(p) => {
632+
return false;
635633
}
636-
Terminal::PkH(ref p) => {
637-
if !pred(p) {
638-
return false;
639-
}
634+
Terminal::PkH(ref p) if !pred(p) => {
635+
return false;
640636
}
641637
// These branches cannot be combined since technically the two `thresh`es
642638
// have different types (have different maximum values).
643-
Terminal::Multi(ref thresh) => {
644-
if !thresh.iter().all(&mut pred) {
645-
return false;
646-
}
639+
Terminal::Multi(ref thresh) if !thresh.iter().all(&mut pred) => {
640+
return false;
647641
}
648-
Terminal::MultiA(ref thresh) => {
649-
if !thresh.iter().all(&mut pred) {
650-
return false;
651-
}
642+
Terminal::MultiA(ref thresh) if !thresh.iter().all(&mut pred) => {
643+
return false;
652644
}
653645
_ => {}
654646
}

src/policy/concrete.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,11 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
153153
fn check_binary_ops(&self) -> Result<(), CompilerError> {
154154
for policy in self.pre_order_iter() {
155155
match *policy {
156-
Policy::And(ref subs) => {
157-
if subs.len() != 2 {
158-
return Err(CompilerError::NonBinaryArgAnd);
159-
}
156+
Policy::And(ref subs) if subs.len() != 2 => {
157+
return Err(CompilerError::NonBinaryArgAnd);
160158
}
161-
Policy::Or(ref subs) => {
162-
if subs.len() != 2 {
163-
return Err(CompilerError::NonBinaryArgOr);
164-
}
159+
Policy::Or(ref subs) if subs.len() != 2 => {
160+
return Err(CompilerError::NonBinaryArgOr);
165161
}
166162
_ => {}
167163
}

0 commit comments

Comments
 (0)