Skip to content

Commit

Permalink
fix: Cargo clippy lints after rust 1.78
Browse files Browse the repository at this point in the history
  • Loading branch information
danielabrozzoni committed May 2, 2024
1 parent 08fac47 commit 5ae04c7
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
10 changes: 6 additions & 4 deletions crates/bdk/src/wallet/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
//! # Ok::<_, Box<dyn std::error::Error>>(())
//! ```
use alloc::string::{String, ToString};
use alloc::string::String;
use core::fmt;
use core::str::FromStr;
use serde::{Deserialize, Serialize};

Expand All @@ -79,9 +80,9 @@ pub struct FullyNodedExport {
pub label: String,
}

impl ToString for FullyNodedExport {
fn to_string(&self) -> String {
serde_json::to_string(self).unwrap()
impl fmt::Display for FullyNodedExport {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", serde_json::to_string(self).unwrap())
}
}

Expand Down Expand Up @@ -216,6 +217,7 @@ mod test {
use bdk_chain::{BlockId, ConfirmationTime};
use bitcoin::hashes::Hash;
use bitcoin::{transaction, BlockHash, Network, Transaction};
use crate::std::string::ToString;

use super::*;
use crate::wallet::Wallet;
Expand Down
4 changes: 2 additions & 2 deletions crates/chain/src/local_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ impl Iterator for CheckPointIter {

fn next(&mut self) -> Option<Self::Item> {
let current = self.current.clone()?;
self.current = current.prev.clone();
self.current.clone_from(&current.prev);
Some(CheckPoint(current))
}
}
Expand Down Expand Up @@ -359,7 +359,7 @@ impl LocalChain {
/// The [`BTreeMap`] enforces the height order. However, the caller must ensure the blocks are
/// all of the same chain.
pub fn from_blocks(blocks: BTreeMap<u32, BlockHash>) -> Result<Self, MissingGenesisError> {
if blocks.get(&0).is_none() {
if !blocks.contains_key(&0) {
return Err(MissingGenesisError);
}

Expand Down
3 changes: 3 additions & 0 deletions crates/chain/src/spk_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ impl<K: Ord + Clone> FullScanRequest<K> {
spks: impl IntoIterator<IntoIter = impl Iterator<Item = (u32, ScriptBuf)> + Send + 'static>,
) -> Self {
match self.spks_by_keychain.remove(&keychain) {
// clippy here suggests to remove `into_iter` from `spks.into_iter()`, but doing so
// results in a compilation error
#[allow(clippy::useless_conversion)]
Some(keychain_spks) => self
.spks_by_keychain
.insert(keychain, Box::new(keychain_spks.chain(spks.into_iter()))),
Expand Down
1 change: 1 addition & 0 deletions crates/chain/src/spk_iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ mod test {
}

// The following dummy traits were created to test if SpkIterator is working properly.
#[allow(unused)]
trait TestSendStatic: Send + 'static {
fn test(&self) -> u32 {
20
Expand Down
2 changes: 1 addition & 1 deletion crates/chain/src/spk_txout_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ impl<I: Clone + Ord> SpkTxOutIndex<I> {
/// Here, "unused" means that after the script pubkey was stored in the index, the index has
/// never scanned a transaction output with it.
pub fn is_used(&self, index: &I) -> bool {
self.unused.get(index).is_none()
!self.unused.contains(index)
}

/// Marks the script pubkey at `index` as used even though it hasn't seen an output spending to it.
Expand Down

0 comments on commit 5ae04c7

Please sign in to comment.