internals: Fix lint warnings on macro

The new `impl_to_hex_from_lower_hex` macro causes build warnings when
`internals` is built without the `alloc` feature.

There are two macro implementations depending on feature gates,
improve the docs and duplicate them ont both macro definitions.
This commit is contained in:
Tobin C. Harding 2024-09-04 16:00:31 +10:00
parent 6fac593ec9
commit 514cc5500f
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
1 changed files with 8 additions and 1 deletions

View File

@ -205,7 +205,10 @@ macro_rules! impl_from_infallible {
}
}
/// Implements `to_hex` for functions that have implemented [`core::fmt::LowerHex`]
/// 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(feature = "alloc")]
macro_rules! impl_to_hex_from_lower_hex {
@ -224,6 +227,10 @@ 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 {