Skip to content

Commit

Permalink
Merge rust-bitcoin#3314: hashes: Use $crate in internal macros
Browse files Browse the repository at this point in the history
d72f730 hashes: Use $crate in internal macros (Tobin C. Harding)

Pull request description:

  These are only called from within the crate but it is still more correct to use `$crate` and saves this from biting us later if we copy the code someplace else.

  Internal change only.

ACKs for top commit:
  Kixunil:
    ACK d72f730
  apoelstra:
    ACK d72f730 successfully ran local tests

Tree-SHA512: d278643c3fbeb28ca377ebf59958054dd2893c46b48469e03a8c7517c5b0b33271de061ae662c400d45962724fe4d13cada41fd5b839a1ff784521ac69c9db72
  • Loading branch information
apoelstra committed Sep 7, 2024
2 parents 9afeb71 + d72f730 commit 2c26dc4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions hashes/src/internal_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,13 @@ macro_rules! hash_trait_impls {
}
}

impl<$($gen: $gent),*> crate::GeneralHash for Hash<$($gen),*> {
impl<$($gen: $gent),*> $crate::GeneralHash for Hash<$($gen),*> {
type Engine = HashEngine;

fn from_engine(e: HashEngine) -> Hash<$($gen),*> { Self::from_engine(e) }
}

impl<$($gen: $gent),*> crate::Hash for Hash<$($gen),*> {
impl<$($gen: $gent),*> $crate::Hash for Hash<$($gen),*> {
type Bytes = [u8; $bits / 8];

const DISPLAY_BACKWARD: bool = $reverse;
Expand Down Expand Up @@ -148,21 +148,21 @@ macro_rules! hash_type {

/// Hashes some bytes.
#[allow(clippy::self_named_constructors)] // Hash is a noun and a verb.
pub fn hash(data: &[u8]) -> Self { <Self as crate::GeneralHash>::hash(data) }
pub fn hash(data: &[u8]) -> Self { <Self as $crate::GeneralHash>::hash(data) }

/// Hashes all the byte slices retrieved from the iterator together.
pub fn hash_byte_chunks<B, I>(byte_slices: I) -> Self
where
B: AsRef<[u8]>,
I: IntoIterator<Item = B>,
{
<Self as crate::GeneralHash>::hash_byte_chunks(byte_slices)
<Self as $crate::GeneralHash>::hash_byte_chunks(byte_slices)
}

/// Hashes the entire contents of the `reader`.
#[cfg(feature = "bitcoin-io")]
pub fn hash_reader<R: io::BufRead>(reader: &mut R) -> Result<Self, io::Error> {
<Self as crate::GeneralHash>::hash_reader(reader)
<Self as $crate::GeneralHash>::hash_reader(reader)
}
}
};
Expand Down Expand Up @@ -245,7 +245,7 @@ macro_rules! hash_type_no_default {
}
}

crate::internal_macros::hash_trait_impls!($bits, $reverse);
$crate::internal_macros::hash_trait_impls!($bits, $reverse);
};
}
pub(crate) use hash_type_no_default;

0 comments on commit 2c26dc4

Please sign in to comment.