diff --git a/bitcoin/src/error.rs b/bitcoin/src/error.rs index 0536c72f..ab296628 100644 --- a/bitcoin/src/error.rs +++ b/bitcoin/src/error.rs @@ -2,22 +2,6 @@ //! Contains error types and other error handling tools. -pub use crate::parse::ParseIntError; +pub(crate) use internals::impl_std_error; -/// Impls std::error::Error for the specified type with appropriate attributes, possibly returning -/// source. -macro_rules! impl_std_error { - // No source available - ($type:ty) => { - #[cfg(feature = "std")] - impl std::error::Error for $type {} - }; - // Struct with $field as source - ($type:ty, $field:ident) => { - #[cfg(feature = "std")] - impl std::error::Error for $type { - fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { Some(&self.$field) } - } - }; -} -pub(crate) use impl_std_error; +pub use crate::parse::ParseIntError; diff --git a/internals/src/error.rs b/internals/src/error.rs index ff596734..d6049fbd 100644 --- a/internals/src/error.rs +++ b/internals/src/error.rs @@ -26,3 +26,21 @@ macro_rules! write_err { } } } + +/// Impls std::error::Error for the specified type with appropriate attributes, possibly returning +/// source. +#[macro_export] +macro_rules! impl_std_error { + // No source available + ($type:ty) => { + #[cfg(feature = "std")] + impl std::error::Error for $type {} + }; + // Struct with $field as source + ($type:ty, $field:ident) => { + #[cfg(feature = "std")] + impl std::error::Error for $type { + fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { Some(&self.$field) } + } + }; +}