Add 0x when printing hex values.

This commit is contained in:
Tomasz Drwięga 2018-02-06 16:19:42 +01:00
parent 3fe9fe605b
commit c06346cc4b
1 changed files with 7 additions and 5 deletions

View File

@ -119,15 +119,14 @@ macro_rules! construct_hash {
impl ::core::fmt::Debug for $from {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
for i in &self.0[..] {
write!(f, "{:02x}", i)?;
}
Ok(())
write!(f, "0x")?;
::core::fmt::LowerHex::fmt(self, f)
}
}
impl ::core::fmt::Display for $from {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
write!(f, "0x")?;
for i in &self.0[0..2] {
write!(f, "{:02x}", i)?;
}
@ -141,7 +140,10 @@ macro_rules! construct_hash {
impl ::core::fmt::LowerHex for $from {
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(())
}
}