Merge pull request #18 from paritytech/td-format
Add 0x when printing hex values.
This commit is contained in:
commit
59c05a4450
12
src/hash.rs
12
src/hash.rs
|
@ -119,15 +119,14 @@ macro_rules! construct_hash {
|
||||||
|
|
||||||
impl ::core::fmt::Debug for $from {
|
impl ::core::fmt::Debug for $from {
|
||||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||||
for i in &self.0[..] {
|
write!(f, "0x")?;
|
||||||
write!(f, "{:02x}", i)?;
|
::core::fmt::LowerHex::fmt(self, f)
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ::core::fmt::Display for $from {
|
impl ::core::fmt::Display for $from {
|
||||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||||
|
write!(f, "0x")?;
|
||||||
for i in &self.0[0..2] {
|
for i in &self.0[0..2] {
|
||||||
write!(f, "{:02x}", i)?;
|
write!(f, "{:02x}", i)?;
|
||||||
}
|
}
|
||||||
|
@ -141,7 +140,10 @@ macro_rules! construct_hash {
|
||||||
|
|
||||||
impl ::core::fmt::LowerHex for $from {
|
impl ::core::fmt::LowerHex for $from {
|
||||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||||
::core::fmt::Debug::fmt(self, f)
|
for i in &self.0[..] {
|
||||||
|
write!(f, "{:02x}", i)?;
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue