Merge rust-bitcoin/rust-bitcoin#3295: internals: Fix lint warnings on macro

514cc5500f internals: Fix lint warnings on macro (Tobin C. Harding)

Pull request description:

  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, duplicate the rustdocs from the other one.

  While we are at it reduce the lines of code for the empty case.

ACKs for top commit:
  Kixunil:
    ACK 514cc5500f
  apoelstra:
    ACK 514cc5500f successfully ran local tests

Tree-SHA512: f6a8929f53be77fed3703858b757fc94bd986dccde417a1cbd8edda67e08f4ff4dc76d5eff7f09a0482a05c9ea330cc45e970f3549fbd0b5f35683dd0243e2a1
This commit is contained in:
merge-script 2024-09-11 16:13:53 +00:00
commit 4cc14d9df8
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
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 {