Merge rust-bitcoin/rust-bitcoin#3365: Move feature flag inside impl_to_hex_from_lower_hex macro
9459739457
Move feature flag inside impl_to_hex_from_lower_hex macro (Shing Him Ng) Pull request description: Moving the feature flag inside the macro definition. Since the feature flag is moved inside the macro def, we don't need to keep the definition of the one behind `#[cfg(not(feature = "alloc"))]` Fixes #3348 ACKs for top commit: apoelstra: ACK9459739457
successfully ran local tests tcharding: ACK9459739457
Tree-SHA512: 47272d3e1def21ef372af04810834da072fc43069a5c0b8ba154910d07526e79693c86cb73de301ce3d0c6cdca92abb7d23ae8346e8ce8b29c961e42e821f0e0
This commit is contained in:
commit
d79b5b9d43
|
@ -208,13 +208,15 @@ macro_rules! impl_from_infallible {
|
||||||
/// Adds an implementation of `pub fn to_hex(&self) -> String` if `alloc` feature is enabled.
|
/// Adds an implementation of `pub fn to_hex(&self) -> String` if `alloc` feature is enabled.
|
||||||
///
|
///
|
||||||
/// The added function allocates a `String` then calls through to [`core::fmt::LowerHex`].
|
/// The added function allocates a `String` then calls through to [`core::fmt::LowerHex`].
|
||||||
/// Calling this macro without the `alloc` feature enabled is a noop.
|
///
|
||||||
|
/// Note: Calling this macro assumes that the calling crate has an `alloc` feature that also activates the
|
||||||
|
/// `alloc` crate. Calling this macro without the `alloc` feature enabled is a no-op.
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
#[cfg(feature = "alloc")]
|
|
||||||
macro_rules! impl_to_hex_from_lower_hex {
|
macro_rules! impl_to_hex_from_lower_hex {
|
||||||
($t:ident, $hex_len_fn:expr) => {
|
($t:ident, $hex_len_fn:expr) => {
|
||||||
impl $t {
|
impl $t {
|
||||||
/// Gets the hex representation of this type
|
/// Gets the hex representation of this type
|
||||||
|
#[cfg(feature = "alloc")]
|
||||||
pub fn to_hex(&self) -> alloc::string::String {
|
pub fn to_hex(&self) -> alloc::string::String {
|
||||||
use core::fmt::Write;
|
use core::fmt::Write;
|
||||||
|
|
||||||
|
@ -226,13 +228,3 @@ macro_rules! impl_to_hex_from_lower_hex {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Adds an implementation of `pub fn to_hex(&self) -> String` if `alloc` feature is enabled.
|
|
||||||
///
|
|
||||||
/// The added function allocates a `String` then calls through to [`core::fmt::LowerHex`].
|
|
||||||
/// Calling this macro without the `alloc` feature enabled is a noop.
|
|
||||||
#[macro_export]
|
|
||||||
#[cfg(not(feature = "alloc"))]
|
|
||||||
macro_rules! impl_to_hex_from_lower_hex {
|
|
||||||
($t:ident, $hex_len_fn:expr) => {};
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue