Skip to content

Commit 68c7c49

Browse files
committed
clippy warnings
1 parent b238366 commit 68c7c49

File tree

17 files changed

+53
-61
lines changed

17 files changed

+53
-61
lines changed

src/descriptor/bare.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ where
192192
where
193193
T: Translator<P, Q, E>,
194194
{
195-
Ok(Bare::new(self.ms.translate_pk(t)?).map_err(TranslateErr::OuterError)?)
195+
Bare::new(self.ms.translate_pk(t)?).map_err(TranslateErr::OuterError)
196196
}
197197
}
198198

src/descriptor/key.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -999,13 +999,13 @@ impl MiniscriptKey for DescriptorPublicKey {
999999
}
10001000

10011001
fn is_x_only_key(&self) -> bool {
1002-
match self {
1002+
matches!(
1003+
self,
10031004
DescriptorPublicKey::Single(SinglePub {
10041005
key: SinglePubKey::XOnly(ref _key),
10051006
..
1006-
}) => true,
1007-
_ => false,
1008-
}
1007+
})
1008+
)
10091009
}
10101010

10111011
fn num_der_paths(&self) -> usize {

src/descriptor/sh.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,13 +348,13 @@ impl<Pk: MiniscriptKey + ToPublicKey> Sh<Pk> {
348348
let witness_script = wsh.inner_script().to_v0_p2wsh();
349349
let push_bytes = <&PushBytes>::try_from(witness_script.as_bytes())
350350
.expect("Witness script is not too large");
351-
script::Builder::new().push_slice(&push_bytes).into_script()
351+
script::Builder::new().push_slice(push_bytes).into_script()
352352
}
353353
ShInner::Wpkh(ref wpkh) => {
354354
let redeem_script = wpkh.script_pubkey();
355355
let push_bytes: &PushBytes =
356356
<&PushBytes>::try_from(redeem_script.as_bytes()).expect("Script not too large");
357-
script::Builder::new().push_slice(&push_bytes).into_script()
357+
script::Builder::new().push_slice(push_bytes).into_script()
358358
}
359359
ShInner::SortedMulti(..) | ShInner::Ms(..) => ScriptBuf::new(),
360360
}

src/descriptor/tr.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ impl<Pk: MiniscriptKey + ToPublicKey> Tr<Pk> {
350350
let builder = bitcoin::blockdata::script::Builder::new();
351351
builder
352352
.push_opcode(opcodes::all::OP_PUSHNUM_1)
353-
.push_slice(&output_key.serialize())
353+
.push_slice(output_key.serialize())
354354
.into_script()
355355
}
356356

@@ -405,8 +405,7 @@ where
405405
type Item = (u8, &'a Miniscript<Pk, Tap>);
406406

407407
fn next(&mut self) -> Option<Self::Item> {
408-
while !self.stack.is_empty() {
409-
let (depth, last) = self.stack.pop().expect("Size checked above");
408+
while let Some((depth, last)) = self.stack.pop() {
410409
match *last {
411410
TapTree::Tree(ref l, ref r) => {
412411
self.stack.push((depth + 1, r));

src/interpreter/inner.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ fn script_from_stack_elem<Ctx: ScriptContext>(
4343
) -> Result<Miniscript<Ctx::Key, Ctx>, Error> {
4444
match *elem {
4545
stack::Element::Push(sl) => {
46-
Miniscript::parse_with_ext(&bitcoin::Script::from_bytes(sl), &ExtParams::allow_all())
46+
Miniscript::parse_with_ext(bitcoin::Script::from_bytes(sl), &ExtParams::allow_all())
4747
.map_err(Error::from)
4848
}
4949
stack::Element::Satisfied => {

src/iter/tree.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ impl<T: TreeLike> Iterator for PreOrderIter<T> {
220220
self.stack.push(left);
221221
}
222222
Tree::Nary(children) => {
223-
self.stack.extend(children.into_iter().rev().cloned());
223+
self.stack.extend(children.iter().rev().cloned());
224224
}
225225
}
226226
Some(top)

src/miniscript/analyzable.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,7 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> Miniscript<Pk, Ctx> {
221221

222222
/// Whether the given miniscript contains a raw pkh fragment
223223
pub fn contains_raw_pkh(&self) -> bool {
224-
self.iter().any(|ms| match ms.node {
225-
Terminal::RawPkH(_) => true,
226-
_ => false,
227-
})
224+
self.iter().any(|ms| matches!(ms.node, Terminal::RawPkH(_)))
228225
}
229226

230227
/// Check whether the underlying Miniscript is safe under the current context

src/miniscript/astelem.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> Terminal<Pk, Ctx> {
465465
Terminal::RawPkH(ref hash) => builder
466466
.push_opcode(opcodes::all::OP_DUP)
467467
.push_opcode(opcodes::all::OP_HASH160)
468-
.push_slice(&hash.to_byte_array())
468+
.push_slice(hash.to_byte_array())
469469
.push_opcode(opcodes::all::OP_EQUALVERIFY),
470470
Terminal::After(t) => builder
471471
.push_int(absolute::LockTime::from(t).to_consensus_u32() as i64)

src/miniscript/context.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,9 +430,7 @@ impl ScriptContext for Legacy {
430430
}
431431
Ok(())
432432
}
433-
Terminal::MultiA(..) => {
434-
return Err(ScriptContextError::MultiANotAllowed);
435-
}
433+
Terminal::MultiA(..) => Err(ScriptContextError::MultiANotAllowed),
436434
_ => Ok(()),
437435
}
438436
}

src/miniscript/decode.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -651,13 +651,12 @@ pub fn parse<Ctx: ScriptContext>(
651651
}
652652

653653
fn is_and_v(tokens: &mut TokenIter) -> bool {
654-
match tokens.peek() {
655-
None
656-
| Some(&Tk::If)
657-
| Some(&Tk::NotIf)
658-
| Some(&Tk::Else)
659-
| Some(&Tk::ToAltStack)
660-
| Some(&Tk::Swap) => false,
661-
_ => true,
662-
}
654+
!matches!(
655+
tokens.peek(),
656+
None | Some(&Tk::If)
657+
| Some(&Tk::NotIf)
658+
| Some(&Tk::Else)
659+
| Some(&Tk::ToAltStack)
660+
| Some(&Tk::Swap)
661+
)
663662
}

0 commit comments

Comments
 (0)