Move feature flag inside impl_to_hex_from_lower_hex macro
This commit is contained in:
parent
85fa0ce28d
commit
9459739457
|
@ -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