From 8f94237ab0e31bd50ae6d7360b3a0f25c1727f58 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 11f5132bc..69f72b6dd 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; @@ -1016,16 +1016,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 689501c21..fa460d6ad 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";