From 6fdd3b1da518e828545dcec54340f9ea6f81c741 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Fri, 14 Jul 2023 14:19:20 +1000 Subject: [PATCH] Clean up hashes import statements Now that we have `hashes` as the crate name of `bitcoin_hashes` we can slightly clean up the import statements. This is based on the convention we have to import things directly from the crate if we depend on it and not from the crate level re-export. --- src/lib.rs | 10 +++++----- src/secret.rs | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index d029312..ae5a816 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -175,6 +175,8 @@ use core::{fmt, mem, str}; #[cfg(feature = "global-context")] pub use context::global::SECP256K1; +#[cfg(feature = "hashes")] +use hashes::Hash; #[cfg(feature = "rand")] pub use rand; pub use secp256k1_sys as ffi; @@ -184,8 +186,6 @@ pub use serde; pub use crate::context::*; use crate::ffi::types::AlignedType; use crate::ffi::CPtr; -#[cfg(feature = "hashes")] -use crate::hashes::Hash; pub use crate::key::{PublicKey, SecretKey, *}; pub use crate::scalar::Scalar; @@ -1046,16 +1046,16 @@ mod tests { #[cfg(feature = "hashes")] #[test] fn test_from_hash() { - use crate::hashes::{self, Hash}; + use hashes::{sha256, sha256d, Hash}; let test_bytes = "Hello world!".as_bytes(); - let hash = hashes::sha256::Hash::hash(test_bytes); + let hash = sha256::Hash::hash(test_bytes); let msg = Message::from(hash); assert_eq!(msg.0, hash.to_byte_array()); assert_eq!(msg, Message::from_hashed_data::(test_bytes)); - let hash = hashes::sha256d::Hash::hash(test_bytes); + let hash = sha256d::Hash::hash(test_bytes); let msg = Message::from(hash); assert_eq!(msg.0, hash.to_byte_array()); assert_eq!(msg, Message::from_hashed_data::(test_bytes)); diff --git a/src/secret.rs b/src/secret.rs index 689501c..fa460d6 100644 --- a/src/secret.rs +++ b/src/secret.rs @@ -35,7 +35,7 @@ macro_rules! impl_display_secret { #[cfg(all(not(feature = "std"), feature = "hashes"))] impl ::core::fmt::Debug for $thing { fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { - use crate::hashes::{sha256, Hash, HashEngine}; + use hashes::{sha256, Hash, HashEngine}; let tag = "rust-secp256k1DEBUG";