diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ca9d36..25a959e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ +# 0.9.6 - 2021-05-03 + +* Re-export `core` as `_export::_core`. This resolves an issue when calling several exported macros with the `std` feature. + # 0.9.5 - 2021-04-28 * Add [`#[repr(transparent)]` to all newtype wrappers](https://github.com/rust-bitcoin/bitcoin_hashes/pull/108/) diff --git a/Cargo.toml b/Cargo.toml index 2951c63..294df8f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bitcoin_hashes" -version = "0.9.5" +version = "0.9.6" authors = ["Andrew Poelstra "] license = "CC0-1.0" description = "Hash functions used by rust-bitcoin which support rustc 1.29.0" diff --git a/src/lib.rs b/src/lib.rs index 2f8a30f..11a56b5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -41,6 +41,14 @@ #[cfg(feature="serde")] pub extern crate serde; #[cfg(all(test,feature="serde"))] extern crate serde_test; +#[doc(hidden)] +pub mod _export { + /// A re-export of ::core::* + pub mod _core { + pub use ::core::*; + } +} + #[cfg(feature = "schemars")] extern crate schemars; #[macro_use] mod util; diff --git a/src/util.rs b/src/util.rs index e0715a8..a86dc3b 100644 --- a/src/util.rs +++ b/src/util.rs @@ -29,8 +29,8 @@ macro_rules! hex_fmt_impl( hex_fmt_impl!($imp, $ty, ); ); ($imp:ident, $ty:ident, $($gen:ident: $gent:ident),*) => ( - impl<$($gen: $gent),*> ::core::fmt::$imp for $ty<$($gen),*> { - fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { + impl<$($gen: $gent),*> $crate::_export::_core::fmt::$imp for $ty<$($gen),*> { + fn fmt(&self, f: &mut $crate::_export::_core::fmt::Formatter) -> $crate::_export::_core::fmt::Result { use $crate::hex::{format_hex, format_hex_reverse}; if $ty::<$($gen),*>::DISPLAY_BACKWARD { format_hex_reverse(&self.0, f) @@ -49,37 +49,37 @@ macro_rules! index_impl( index_impl!($ty, ); ); ($ty:ident, $($gen:ident: $gent:ident),*) => ( - impl<$($gen: $gent),*> ::core::ops::Index for $ty<$($gen),*> { + impl<$($gen: $gent),*> $crate::_export::_core::ops::Index for $ty<$($gen),*> { type Output = u8; fn index(&self, index: usize) -> &u8 { &self.0[index] } } - impl<$($gen: $gent),*> ::core::ops::Index<::core::ops::Range> for $ty<$($gen),*> { + impl<$($gen: $gent),*> $crate::_export::_core::ops::Index<$crate::_export::_core::ops::Range> for $ty<$($gen),*> { type Output = [u8]; - fn index(&self, index: ::core::ops::Range) -> &[u8] { + fn index(&self, index: $crate::_export::_core::ops::Range) -> &[u8] { &self.0[index] } } - impl<$($gen: $gent),*> ::core::ops::Index<::core::ops::RangeFrom> for $ty<$($gen),*> { + impl<$($gen: $gent),*> $crate::_export::_core::ops::Index<$crate::_export::_core::ops::RangeFrom> for $ty<$($gen),*> { type Output = [u8]; - fn index(&self, index: ::core::ops::RangeFrom) -> &[u8] { + fn index(&self, index: $crate::_export::_core::ops::RangeFrom) -> &[u8] { &self.0[index] } } - impl<$($gen: $gent),*> ::core::ops::Index<::core::ops::RangeTo> for $ty<$($gen),*> { + impl<$($gen: $gent),*> $crate::_export::_core::ops::Index<$crate::_export::_core::ops::RangeTo> for $ty<$($gen),*> { type Output = [u8]; - fn index(&self, index: ::core::ops::RangeTo) -> &[u8] { + fn index(&self, index: $crate::_export::_core::ops::RangeTo) -> &[u8] { &self.0[index] } } - impl<$($gen: $gent),*> ::core::ops::Index<::core::ops::RangeFull> for $ty<$($gen),*> { + impl<$($gen: $gent),*> $crate::_export::_core::ops::Index<$crate::_export::_core::ops::RangeFull> for $ty<$($gen),*> { type Output = [u8]; - fn index(&self, index: ::core::ops::RangeFull) -> &[u8] { + fn index(&self, index: $crate::_export::_core::ops::RangeFull) -> &[u8] { &self.0[index] } } @@ -93,19 +93,19 @@ macro_rules! borrow_slice_impl( borrow_slice_impl!($ty, ); ); ($ty:ident, $($gen:ident: $gent:ident),*) => ( - impl<$($gen: $gent),*> ::core::borrow::Borrow<[u8]> for $ty<$($gen),*> { + impl<$($gen: $gent),*> $crate::_export::_core::borrow::Borrow<[u8]> for $ty<$($gen),*> { fn borrow(&self) -> &[u8] { &self[..] } } - impl<$($gen: $gent),*> ::core::convert::AsRef<[u8]> for $ty<$($gen),*> { + impl<$($gen: $gent),*> $crate::_export::_core::convert::AsRef<[u8]> for $ty<$($gen),*> { fn as_ref(&self) -> &[u8] { &self[..] } } - impl<$($gen: $gent),*> ::core::ops::Deref for $ty<$($gen),*> { + impl<$($gen: $gent),*> $crate::_export::_core::ops::Deref for $ty<$($gen),*> { type Target = [u8]; fn deref(&self) -> &Self::Target { @@ -241,14 +241,14 @@ macro_rules! hash_newtype { } } - impl ::core::convert::From<$hash> for $newtype { + impl $crate::_export::_core::convert::From<$hash> for $newtype { fn from(inner: $hash) -> $newtype { // Due to rust 1.22 we have to use this instead of simple `Self(inner)` Self { 0: inner } } } - impl ::core::convert::From<$newtype> for $hash { + impl $crate::_export::_core::convert::From<$newtype> for $hash { fn from(hashtype: $newtype) -> $hash { hashtype.0 } @@ -290,9 +290,9 @@ macro_rules! hash_newtype { } } - impl ::core::str::FromStr for $newtype { + impl $crate::_export::_core::str::FromStr for $newtype { type Err = $crate::hex::Error; - fn from_str(s: &str) -> ::core::result::Result<$newtype, Self::Err> { + fn from_str(s: &str) -> $crate::_export::_core::result::Result<$newtype, Self::Err> { $crate::hex::FromHex::from_hex(s) } }