Skip to content

Commit ce3eeea

Browse files
fix: Cargo clippy lints after rust 1.78
1 parent 08fac47 commit ce3eeea

4 files changed

Lines changed: 11 additions & 7 deletions

File tree

crates/bdk/src/wallet/export.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@
5353
//! # Ok::<_, Box<dyn std::error::Error>>(())
5454
//! ```
5555
56-
use alloc::string::{String, ToString};
56+
use alloc::string::String;
5757
use core::str::FromStr;
58+
use core::fmt;
5859
use serde::{Deserialize, Serialize};
5960

6061
use miniscript::descriptor::{ShInner, WshInner};
@@ -79,9 +80,9 @@ pub struct FullyNodedExport {
7980
pub label: String,
8081
}
8182

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

crates/chain/src/local_chain.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ impl Iterator for CheckPointIter {
265265

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

crates/chain/src/spk_client.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,9 @@ impl<K: Ord + Clone> FullScanRequest<K> {
255255
spks: impl IntoIterator<IntoIter = impl Iterator<Item = (u32, ScriptBuf)> + Send + 'static>,
256256
) -> Self {
257257
match self.spks_by_keychain.remove(&keychain) {
258+
// clippy here suggests to remove `into_iter` from `spks.into_iter()`, but doing so
259+
// results in a compilation error
260+
#[allow(clippy::useless_conversion)]
258261
Some(keychain_spks) => self
259262
.spks_by_keychain
260263
.insert(keychain, Box::new(keychain_spks.chain(spks.into_iter()))),

crates/chain/src/spk_txout_index.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ impl<I: Clone + Ord> SpkTxOutIndex<I> {
229229
/// Here, "unused" means that after the script pubkey was stored in the index, the index has
230230
/// never scanned a transaction output with it.
231231
pub fn is_used(&self, index: &I) -> bool {
232-
self.unused.get(index).is_none()
232+
!self.unused.contains(index)
233233
}
234234

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

0 commit comments

Comments
 (0)