Remove the `:#` formatting for `hex_fmt_impl` macro
This fixes the issue where pretty debug like `dbg` or `{:#}` introduce the use of `0x` prefix to hex encoded transaction ID. The transaction id is being forced to pretty print inside the `hex_fmt_impl` macro using `{:#}` in the line `write!(f, "{:#}", self)` debug formatter. Resolves: #2505
This commit is contained in:
parent
b3273cfcb8
commit
56132f59d5
|
@ -2444,6 +2444,29 @@ mod tests {
|
|||
let seq = Sequence::from_seconds_floor(1000);
|
||||
println!("{:?}", seq)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn outpoint_format() {
|
||||
let outpoint = OutPoint::default();
|
||||
|
||||
let debug = "OutPoint { txid: 0000000000000000000000000000000000000000000000000000000000000000, vout: 4294967295 }";
|
||||
assert_eq!(debug, format!("{:?}", &outpoint));
|
||||
|
||||
let display = "0000000000000000000000000000000000000000000000000000000000000000:4294967295";
|
||||
assert_eq!(display, format!("{}", &outpoint));
|
||||
|
||||
let pretty_debug = "OutPoint {\n txid: 0000000000000000000000000000000000000000000000000000000000000000,\n vout: 4294967295,\n}";
|
||||
assert_eq!(pretty_debug, format!("{:#?}", &outpoint));
|
||||
|
||||
let debug_txid = "0000000000000000000000000000000000000000000000000000000000000000";
|
||||
assert_eq!(debug_txid, format!("{:?}", &outpoint.txid));
|
||||
|
||||
let display_txid = "0000000000000000000000000000000000000000000000000000000000000000";
|
||||
assert_eq!(display_txid, format!("{}", &outpoint.txid));
|
||||
|
||||
let pretty_txid = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
||||
assert_eq!(pretty_txid, format!("{:#}", &outpoint.txid));
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(bench)]
|
||||
|
|
|
@ -39,7 +39,7 @@ macro_rules! hex_fmt_impl(
|
|||
impl<$($gen: $gent),*> $crate::_export::_core::fmt::Debug for $ty<$($gen),*> {
|
||||
#[inline]
|
||||
fn fmt(&self, f: &mut $crate::_export::_core::fmt::Formatter) -> $crate::_export::_core::fmt::Result {
|
||||
write!(f, "{:#}", self)
|
||||
write!(f, "{}", self)
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue