Browse Source

Nicer debug printing for oids, too

pull/80/head
Sebastian Thiel 4 weeks ago
parent
commit
b4f94f8af6
No known key found for this signature in database GPG Key ID: 9CB5EE7895E8268B
  1. 14
      git-hash/src/borrowed.rs

14
git-hash/src/borrowed.rs

@ -13,7 +13,7 @@ use std::{convert::TryInto, fmt};
/// hash `[`kind()`][oid::kind()]`.
/// We expect to have quite a few bits available for such 'conflict resolution' as most hashes aren't longer
/// than 64 bytes.
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd)]
#[derive(PartialEq, Eq, Hash, Ord, PartialOrd)]
#[repr(transparent)]
#[allow(non_camel_case_types)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize))]
@ -21,6 +21,18 @@ pub struct oid {
bytes: [u8],
}
impl std::fmt::Debug for oid {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.kind() {
crate::Kind::Sha1 => f.write_str("Sha1(")?,
}
for b in self.as_bytes() {
write!(f, "{:02x}", b)?;
}
f.write_str(")")
}
}
use quick_error::quick_error;
quick_error! {

Loading…
Cancel
Save