What changed, and why it matters
This commit adds standard Rust formatting traits (LowerHex, UpperHex, Binary, Octal) to the WitnessVersion type, which is a small API ergonomics improvement. There is no security relevance in the diff itself.
No security action required; treat as routine API enhancement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change implements four additional fmt traits for WitnessVersion by delegating to the underlying numeric representation via self.to_num(). It is a pure additive API change following Rust API guidelines (C-NUM-FMT). No parsing, serialization, consensus, or cryptographic logic is modified.
Changed components
primitives/src/witness_version.rsInspect captured patch +20 / −0
diff --git a/primitives/src/witness_version.rs b/primitives/src/witness_version.rs
index e689cb68..6707eee4 100644
--- a/primitives/src/witness_version.rs
+++ b/primitives/src/witness_version.rs
@@ -81,6 +81,26 @@ impl fmt::Display for WitnessVersion {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", *self as u8) }
}
+impl fmt::LowerHex for WitnessVersion {
+ #[inline]
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::LowerHex::fmt(&self.to_num(), f) }
+}
+
+impl fmt::UpperHex for WitnessVersion {
+ #[inline]
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::UpperHex::fmt(&self.to_num(), f) }
+}
+
+impl fmt::Octal for WitnessVersion {
+ #[inline]
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Octal::fmt(&self.to_num(), f) }
+}
+
+impl fmt::Binary for WitnessVersion {
+ #[inline]
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { fmt::Binary::fmt(&self.to_num(), f) }
+}
+
impl FromStr for WitnessVersion {
type Err = ParseWitnessVersionError;
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.