Skip to content

Commit cbc8454

Browse files
committed
chore: make clippy happy
1 parent c9467dc commit cbc8454

File tree

9 files changed

+16
-35
lines changed

9 files changed

+16
-35
lines changed

.github/workflows/cont_integration.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ jobs:
118118
- uses: actions/checkout@v1
119119
- uses: actions-rs/toolchain@v1
120120
with:
121-
toolchain: "stable"
121+
toolchain: stable
122122
components: clippy
123123
override: true
124124
- name: Rust Cache

clippy.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
msrv="1.57.0"
1+
msrv="1.63.0"

crates/bdk/src/descriptor/template.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ mod test {
575575

576576
if let ExtendedDescriptor::Pkh(pkh) = xdesc.0 {
577577
let path: Vec<ChildNumber> = pkh.into_inner().full_derivation_path().unwrap().into();
578-
let purpose = path.get(0).unwrap();
578+
let purpose = path.first().unwrap();
579579
assert_matches!(purpose, Hardened { index: 44 });
580580
let coin_type = path.get(1).unwrap();
581581
assert_matches!(coin_type, Hardened { index: 0 });
@@ -589,7 +589,7 @@ mod test {
589589

590590
if let ExtendedDescriptor::Pkh(pkh) = tdesc.0 {
591591
let path: Vec<ChildNumber> = pkh.into_inner().full_derivation_path().unwrap().into();
592-
let purpose = path.get(0).unwrap();
592+
let purpose = path.first().unwrap();
593593
assert_matches!(purpose, Hardened { index: 44 });
594594
let coin_type = path.get(1).unwrap();
595595
assert_matches!(coin_type, Hardened { index: 1 });

crates/bdk/src/wallet/signer.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -812,9 +812,10 @@ pub struct SignOptions {
812812
}
813813

814814
/// Customize which taproot script-path leaves the signer should sign.
815-
#[derive(Debug, Clone, PartialEq, Eq)]
815+
#[derive(Default, Debug, Clone, PartialEq, Eq)]
816816
pub enum TapLeavesOptions {
817817
/// The signer will sign all the leaves it has a key for.
818+
#[default]
818819
All,
819820
/// The signer won't sign leaves other than the ones specified. Note that it could still ignore
820821
/// some of the specified leaves, if it doesn't have the right key to sign them.
@@ -825,12 +826,6 @@ pub enum TapLeavesOptions {
825826
None,
826827
}
827828

828-
impl Default for TapLeavesOptions {
829-
fn default() -> Self {
830-
TapLeavesOptions::All
831-
}
832-
}
833-
834829
#[allow(clippy::derivable_impls)]
835830
impl Default for SignOptions {
836831
fn default() -> Self {

crates/bdk/src/wallet/tx_builder.rs

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -811,22 +811,17 @@ impl<'a, D> TxBuilder<'a, D, DefaultCoinSelectionAlgorithm, BumpFee> {
811811
}
812812

813813
/// Ordering of the transaction's inputs and outputs
814-
#[derive(Debug, Ord, PartialOrd, Eq, PartialEq, Hash, Clone, Copy)]
814+
#[derive(Default, Debug, Ord, PartialOrd, Eq, PartialEq, Hash, Clone, Copy)]
815815
pub enum TxOrdering {
816816
/// Randomized (default)
817+
#[default]
817818
Shuffle,
818819
/// Unchanged
819820
Untouched,
820821
/// BIP69 / Lexicographic
821822
Bip69Lexicographic,
822823
}
823824

824-
impl Default for TxOrdering {
825-
fn default() -> Self {
826-
TxOrdering::Shuffle
827-
}
828-
}
829-
830825
impl TxOrdering {
831826
/// Sort transaction inputs and outputs by [`TxOrdering`] variant
832827
pub fn sort_tx(&self, tx: &mut Transaction) {
@@ -880,22 +875,17 @@ impl RbfValue {
880875
}
881876

882877
/// Policy regarding the use of change outputs when creating a transaction
883-
#[derive(Debug, Ord, PartialOrd, Eq, PartialEq, Hash, Clone, Copy)]
878+
#[derive(Default, Debug, Ord, PartialOrd, Eq, PartialEq, Hash, Clone, Copy)]
884879
pub enum ChangeSpendPolicy {
885880
/// Use both change and non-change outputs (default)
881+
#[default]
886882
ChangeAllowed,
887883
/// Only use change outputs (see [`TxBuilder::only_spend_change`])
888884
OnlyChange,
889885
/// Only use non-change outputs (see [`TxBuilder::do_not_spend_change`])
890886
ChangeForbidden,
891887
}
892888

893-
impl Default for ChangeSpendPolicy {
894-
fn default() -> Self {
895-
ChangeSpendPolicy::ChangeAllowed
896-
}
897-
}
898-
899889
impl ChangeSpendPolicy {
900890
pub(crate) fn is_satisfied_by(&self, utxo: &LocalOutput) -> bool {
901891
match self {

crates/chain/src/spk_txout_index.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,7 @@ impl<I: Clone + Ord> SpkTxOutIndex<I> {
168168
///
169169
/// Returns `None` if the `TxOut` hasn't been scanned or if nothing matching was found there.
170170
pub fn txout(&self, outpoint: OutPoint) -> Option<(&I, &TxOut)> {
171-
self.txouts
172-
.get(&outpoint)
173-
.map(|(spk_i, txout)| (spk_i, txout))
171+
self.txouts.get(&outpoint).map(|v| (&v.0, &v.1))
174172
}
175173

176174
/// Returns the script that has been inserted at the `index`.

crates/chain/src/tx_graph.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -581,10 +581,7 @@ impl<A: Clone + Ord> TxGraph<A> {
581581
}
582582

583583
for (outpoint, txout) in changeset.txouts {
584-
let tx_entry = self
585-
.txs
586-
.entry(outpoint.txid)
587-
.or_insert_with(Default::default);
584+
let tx_entry = self.txs.entry(outpoint.txid).or_default();
588585

589586
match tx_entry {
590587
(TxNodeInternal::Whole(_), _, _) => { /* do nothing since we already have full tx */
@@ -597,13 +594,13 @@ impl<A: Clone + Ord> TxGraph<A> {
597594

598595
for (anchor, txid) in changeset.anchors {
599596
if self.anchors.insert((anchor.clone(), txid)) {
600-
let (_, anchors, _) = self.txs.entry(txid).or_insert_with(Default::default);
597+
let (_, anchors, _) = self.txs.entry(txid).or_default();
601598
anchors.insert(anchor);
602599
}
603600
}
604601

605602
for (txid, new_last_seen) in changeset.last_seen {
606-
let (_, _, last_seen) = self.txs.entry(txid).or_insert_with(Default::default);
603+
let (_, _, last_seen) = self.txs.entry(txid).or_default();
607604
if new_last_seen > *last_seen {
608605
*last_seen = new_last_seen;
609606
}

crates/chain/tests/common/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
mod tx_template;
2+
#[allow(unused_imports)]
23
pub use tx_template::*;
34

45
#[allow(unused_macros)]

crates/electrum/src/electrum_ext.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ fn populate_with_txids(
477477

478478
let spk = tx
479479
.output
480-
.get(0)
480+
.first()
481481
.map(|txo| &txo.script_pubkey)
482482
.expect("tx must have an output");
483483

0 commit comments

Comments
 (0)