Skip to content

Commit fb4c33b

Browse files
committed
Use if let and panic
Clippy emits: warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` The code in question is functionally asserting that the `witness` argument does not contain variant `Threshold`, the same can be achieved using an `if let` and a `panic`.
1 parent b0cd8c1 commit fb4c33b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/policy/semantic.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,11 @@ impl<Pk: MiniscriptKey> Policy<Pk> {
223223
// a normalized policy
224224
pub(crate) fn satisfy_constraint(self, witness: &Policy<Pk>, available: bool) -> Policy<Pk> {
225225
debug_assert!(self.clone().normalized() == self);
226-
match *witness {
227-
// only for internal purposes, safe to use unreachable!
228-
Policy::Threshold(..) => unreachable!(),
229-
_ => {}
230-
};
226+
if let Policy::Threshold { .. } = *witness {
227+
// We can't debug_assert on Policy::Threshold.
228+
panic!("should be unreachable")
229+
}
230+
231231
let ret = match self {
232232
Policy::Threshold(k, subs) => {
233233
let mut ret_subs = vec![];

0 commit comments

Comments
 (0)