Correctly feature gate impl_to_hex_from_lower_hex
Currently we feature gate code within the `impl_to_hex_from_lower_hex` macro on "alloc" but `bitcoin` does not have the "alloc" feature so this code is never built in. This can be seen by the lack of a `to_hex` function on `LeafVersion`. Remove the feature gate from the macro and put it on the individual call sites as needed.
This commit is contained in:
parent
57769f5f28
commit
bafe11d7e4
|
@ -219,7 +219,6 @@ macro_rules! impl_to_hex_from_lower_hex {
|
|||
($t:ident, $hex_len_fn:expr) => {
|
||||
impl $t {
|
||||
/// Gets the hex representation of this type
|
||||
#[cfg(feature = "alloc")]
|
||||
pub fn to_hex(&self) -> alloc::string::String {
|
||||
use core::fmt::Write;
|
||||
|
||||
|
|
|
@ -4,8 +4,6 @@
|
|||
|
||||
use core::fmt;
|
||||
|
||||
use internals::impl_to_hex_from_lower_hex;
|
||||
|
||||
/// Encoding of 256-bit target as 32-bit float.
|
||||
///
|
||||
/// This is used to encode a target into the block header. Satoshi made this part of consensus code
|
||||
|
@ -36,7 +34,8 @@ impl fmt::LowerHex for CompactTarget {
|
|||
#[inline]
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::LowerHex::fmt(&self.0, f) }
|
||||
}
|
||||
impl_to_hex_from_lower_hex!(CompactTarget, |compact_target: &CompactTarget| {
|
||||
#[cfg(feature = "alloc")]
|
||||
internals::impl_to_hex_from_lower_hex!(CompactTarget, |compact_target: &CompactTarget| {
|
||||
8 - compact_target.0.leading_zeros() as usize / 4
|
||||
});
|
||||
|
||||
|
|
|
@ -12,7 +12,6 @@ use core::fmt;
|
|||
use core::ops::{Deref, DerefMut};
|
||||
|
||||
use hex::DisplayHex;
|
||||
use internals::impl_to_hex_from_lower_hex;
|
||||
use internals::script::{self, PushDataLenLen};
|
||||
|
||||
use crate::opcodes::all::*;
|
||||
|
@ -231,13 +230,15 @@ impl fmt::LowerHex for Script {
|
|||
fmt::LowerHex::fmt(&self.as_bytes().as_hex(), f)
|
||||
}
|
||||
}
|
||||
impl_to_hex_from_lower_hex!(Script, |script: &Script| script.len() * 2);
|
||||
#[cfg(feature = "alloc")]
|
||||
internals::impl_to_hex_from_lower_hex!(Script, |script: &Script| script.len() * 2);
|
||||
|
||||
impl fmt::LowerHex for ScriptBuf {
|
||||
#[inline]
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::LowerHex::fmt(self.as_script(), f) }
|
||||
}
|
||||
impl_to_hex_from_lower_hex!(ScriptBuf, |script_buf: &ScriptBuf| script_buf.len() * 2);
|
||||
#[cfg(feature = "alloc")]
|
||||
internals::impl_to_hex_from_lower_hex!(ScriptBuf, |script_buf: &ScriptBuf| script_buf.len() * 2);
|
||||
|
||||
impl fmt::UpperHex for Script {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
|
|
|
@ -19,7 +19,6 @@ use core::fmt;
|
|||
|
||||
#[cfg(feature = "arbitrary")]
|
||||
use arbitrary::{Arbitrary, Unstructured};
|
||||
use internals::impl_to_hex_from_lower_hex;
|
||||
#[cfg(feature = "serde")]
|
||||
use serde::{Deserialize, Serialize};
|
||||
#[cfg(feature = "alloc")]
|
||||
|
@ -231,7 +230,8 @@ impl fmt::Display for Sequence {
|
|||
impl fmt::LowerHex for Sequence {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::LowerHex::fmt(&self.0, f) }
|
||||
}
|
||||
impl_to_hex_from_lower_hex!(Sequence, |sequence: &Sequence| {
|
||||
#[cfg(feature = "alloc")]
|
||||
internals::impl_to_hex_from_lower_hex!(Sequence, |sequence: &Sequence| {
|
||||
8 - sequence.0.leading_zeros() as usize / 4
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue