What changed, and why it matters
This commit is a simple code cleanup with no security relevance. It replaces long-form calls like `fmt::Display::fmt(value, formatter)` with shorter `value.fmt(formatter)` calls inside formatting trait implementations. The behavior is identical; only the syntax is shorter.
No action needed. This is a non-security refactoring change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies crypto/src/key.rs to use method-call syntax (.fmt(f)) instead of fully-qualified trait syntax (fmt::Trait::fmt(..., f)) within fmt::LowerHex, fmt::Display, and fmt::Debug implementations for XOnlyPublicKey, LegacyPublicKey, FullPublicKey, TweakedPublicKey, and SerializedXOnlyPublicKey. This is a pure refactoring with no functional change.
Changed components
crypto/src/key.rsInspect captured patch +8 / −15
diff --git a/crypto/src/key.rs b/crypto/src/key.rs
index 5efc8fb8..138e60bb 100644
--- a/crypto/src/key.rs
+++ b/crypto/src/key.rs
@@ -465,7 +465,7 @@ impl From<TweakedPublicKey> for XOnlyPublicKey {
impl fmt::LowerHex for XOnlyPublicKey {
#[inline]
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::LowerHex::fmt(self.as_inner(), f) }
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.as_inner().fmt(f) }
}
// Allocate for serialized size
#[cfg(feature = "alloc")]
@@ -473,7 +473,7 @@ impl_to_hex_from_lower_hex!(XOnlyPublicKey, |_| constants::SCHNORR_PUBLIC_KEY_SI
impl fmt::Display for XOnlyPublicKey {
#[inline]
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Display::fmt(self.as_inner(), f) }
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.as_inner().fmt(f) }
}
// XOnlyPublicKey should serialize/deserialize identically to the inner type.
@@ -822,9 +822,7 @@ pub struct SortKey(ArrayVec<u8, 65>);
impl fmt::Display for LegacyPublicKey {
#[inline]
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- fmt::Display::fmt(&self.to_bytes().as_hex(), f)
- }
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.to_bytes().as_hex().fmt(f) }
}
impl FromStr for LegacyPublicKey {
@@ -968,9 +966,7 @@ impl FullPublicKey {
impl fmt::Display for FullPublicKey {
#[inline]
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- fmt::Display::fmt(&self.to_bytes().as_hex(), f)
- }
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.to_bytes().as_hex().fmt(f) }
}
impl fmt::Debug for FullPublicKey {
@@ -1431,14 +1427,13 @@ impl<'de> serde::Deserialize<'de> for FullPublicKey {
}
}
}
+
/// Untweaked BIP-0340 X-coord-only public key.
pub type UntweakedPublicKey = XOnlyPublicKey;
impl fmt::LowerHex for TweakedPublicKey {
#[inline]
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- fmt::LowerHex::fmt(self.as_x_only_public_key(), f)
- }
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.as_x_only_public_key().fmt(f) }
}
// Allocate for serialized size
#[cfg(feature = "alloc")]
@@ -1446,9 +1441,7 @@ impl_to_hex_from_lower_hex!(TweakedPublicKey, |_| constants::SCHNORR_PUBLIC_KEY_
impl fmt::Display for TweakedPublicKey {
#[inline]
- fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- fmt::Display::fmt(self.as_x_only_public_key(), f)
- }
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { self.as_x_only_public_key().fmt(f) }
}
/// Untweaked BIP-0340 key pair.
@@ -1519,7 +1512,7 @@ impl From<&Self> for SerializedXOnlyPublicKey {
impl fmt::Debug for SerializedXOnlyPublicKey {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- fmt::Debug::fmt(&self.as_byte_array().as_hex(), f)
+ self.as_byte_array().as_hex().fmt(f)
}
}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.