Use the anonymous lifetime for paths

New clippy lint in rustc nightly "lifetime flowing from input to output
with different syntax can be confusing".

Apply the suggested fix and use the anonymous lifetime for paths.
This commit is contained in:
Jamil Lambert, PhD 2025-06-09 09:31:55 +01:00
parent 17cd382327
commit 8e60711265
No known key found for this signature in database
GPG Key ID: 54DC29234AB5D2C0
6 changed files with 12 additions and 12 deletions

View File

@ -416,17 +416,17 @@ impl DerivationPath {
/// Get an [Iterator] over the children of this [DerivationPath]
/// starting with the given [ChildNumber].
pub fn children_from(&self, cn: ChildNumber) -> DerivationPathIterator {
pub fn children_from(&self, cn: ChildNumber) -> DerivationPathIterator<'_> {
DerivationPathIterator::start_from(self, cn)
}
/// Get an [Iterator] over the unhardened children of this [DerivationPath].
pub fn normal_children(&self) -> DerivationPathIterator {
pub fn normal_children(&self) -> DerivationPathIterator<'_> {
DerivationPathIterator::start_from(self, ChildNumber::Normal { index: 0 })
}
/// Get an [Iterator] over the hardened children of this [DerivationPath].
pub fn hardened_children(&self) -> DerivationPathIterator {
pub fn hardened_children(&self) -> DerivationPathIterator<'_> {
DerivationPathIterator::start_from(self, ChildNumber::Hardened { index: 0 })
}

View File

@ -331,7 +331,7 @@ crate::internal_macros::define_extension_trait! {
///
/// To force minimal pushes, use [`instructions_minimal`](Self::instructions_minimal).
#[inline]
fn instructions(&self) -> Instructions {
fn instructions(&self) -> Instructions<'_> {
Instructions { data: self.as_bytes().iter(), enforce_minimal: false }
}
@ -340,7 +340,7 @@ crate::internal_macros::define_extension_trait! {
/// This is similar to [`instructions`](Self::instructions) but an error is returned if a push
/// is not minimal.
#[inline]
fn instructions_minimal(&self) -> Instructions {
fn instructions_minimal(&self) -> Instructions<'_> {
Instructions { data: self.as_bytes().iter(), enforce_minimal: true }
}
@ -352,7 +352,7 @@ crate::internal_macros::define_extension_trait! {
///
/// To force minimal pushes, use [`Self::instruction_indices_minimal`].
#[inline]
fn instruction_indices(&self) -> InstructionIndices {
fn instruction_indices(&self) -> InstructionIndices<'_> {
InstructionIndices::from_instructions(self.instructions())
}
@ -361,7 +361,7 @@ crate::internal_macros::define_extension_trait! {
/// This is similar to [`instruction_indices`](Self::instruction_indices) but an error is
/// returned if a push is not minimal.
#[inline]
fn instruction_indices_minimal(&self) -> InstructionIndices {
fn instruction_indices_minimal(&self) -> InstructionIndices<'_> {
InstructionIndices::from_instructions(self.instructions_minimal())
}

View File

@ -404,7 +404,7 @@ impl TransactionExt for Transaction {
fn is_lock_time_enabled(&self) -> bool { self.input.iter().any(|i| i.enables_lock_time()) }
fn script_pubkey_lens(&self) -> TxOutToScriptPubkeyLengthIter {
fn script_pubkey_lens(&self) -> TxOutToScriptPubkeyLengthIter<'_> {
TxOutToScriptPubkeyLengthIter { inner: self.output.iter() }
}

View File

@ -779,7 +779,7 @@ impl TapTree {
/// Returns [`TapTreeIter<'_>`] iterator for a Taproot script tree, operating in DFS order over
/// tree [`ScriptLeaf`]s.
pub fn script_leaves(&self) -> ScriptLeaves { ScriptLeaves { leaf_iter: self.0.leaf_nodes() } }
pub fn script_leaves(&self) -> ScriptLeaves<'_> { ScriptLeaves { leaf_iter: self.0.leaf_nodes() } }
/// Returns the root [`TapNodeHash`] of this tree.
pub fn root_hash(&self) -> TapNodeHash { self.0.hash }
@ -951,7 +951,7 @@ impl NodeInfo {
}
/// Creates an iterator over all leaves (including hidden leaves) in the tree.
pub fn leaf_nodes(&self) -> LeafNodes { LeafNodes { leaf_iter: self.leaves.iter() } }
pub fn leaf_nodes(&self) -> LeafNodes<'_> { LeafNodes { leaf_iter: self.leaves.iter() } }
/// Returns the root [`TapNodeHash`] of this node info.
pub fn node_hash(&self) -> TapNodeHash { self.hash }

View File

@ -85,7 +85,7 @@ pub trait Read {
/// Constructs a new adapter which will read at most `limit` bytes.
#[inline]
fn take(&mut self, limit: u64) -> Take<Self> { Take { reader: self, remaining: limit } }
fn take(&mut self, limit: u64) -> Take<'_, Self> { Take { reader: self, remaining: limit } }
/// Attempts to read up to limit bytes from the reader, allocating space in `buf` as needed.
///

View File

@ -111,7 +111,7 @@ impl Witness {
/// Returns a struct implementing [`Iterator`].
#[must_use = "iterators are lazy and do nothing unless consumed"]
#[inline]
pub fn iter(&self) -> Iter {
pub fn iter(&self) -> Iter<'_> {
Iter { inner: self.content.as_slice(), indices_start: self.indices_start, current_index: 0 }
}