mirror of
https://github.com/mimblewimble/grin.git
synced 2025-01-21 03:21:08 +03:00
Replace default fmt::Display on core::Hash (#2325)
* Print block hash in TUI partially * Implement fmt::Display for core::Hash * Show first 12 digits of Hash * Show full hex string of hash in fmt::Debug for core::Hash * Strip hash in fmt::Debug and use fmt::Debug for fmt::Display
This commit is contained in:
commit
27b4e2145a
1 changed files with 4 additions and 4 deletions
|
@ -38,10 +38,10 @@ pub struct Hash([u8; 32]);
|
||||||
|
|
||||||
impl fmt::Debug for Hash {
|
impl fmt::Debug for Hash {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
for i in self.0[..4].iter() {
|
let hash_hex = self.to_hex();
|
||||||
write!(f, "{:02x}", i)?;
|
const NUM_SHOW: usize = 12;
|
||||||
}
|
|
||||||
Ok(())
|
write!(f, "{}...", &hash_hex[..NUM_SHOW])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue