diff --git a/crates/primitives/Cargo.toml b/crates/primitives/Cargo.toml index 190df6198..9261d5bfe 100644 --- a/crates/primitives/Cargo.toml +++ b/crates/primitives/Cargo.toml @@ -66,3 +66,7 @@ arbitrary = [ "dep:proptest", "dep:proptest-derive", ] + +# `const-hex` compatibility feature for `hex`. +# Should not be needed most of the time. +hex-compat = ["hex/hex"] diff --git a/crates/primitives/src/bits/macros.rs b/crates/primitives/src/bits/macros.rs index 776bf634e..56b760e02 100644 --- a/crates/primitives/src/bits/macros.rs +++ b/crates/primitives/src/bits/macros.rs @@ -375,7 +375,9 @@ macro_rules! impl_fb_traits { where T: $crate::private::AsRef<[u8]> { - $crate::hex::FromHex::from_hex(hex).map(Self) + let mut buf = [0u8; $n]; + $crate::hex::decode_to_slice(hex.as_ref(), &mut buf)?; + Ok(Self::new(buf)) } } };