diff --git a/crates/radicle-oid/src/lib.rs b/crates/radicle-oid/src/lib.rs index 3568ffa5..1c2bc90a 100644 --- a/crates/radicle-oid/src/lib.rs +++ b/crates/radicle-oid/src/lib.rs @@ -87,6 +87,11 @@ pub enum Oid { // for forwards compatibility: What if another hash with digests of the same // length becomes popular? impl Oid { + /// A SHA-1 object identifier with all digest bytes set to zero. + /// This is sometimes used as a sentinel value to indicate the absence of + /// an object. + /// To compare whether an object identifier is zero, prefer the method + /// [`Oid::is_zero`] over checking equality with this constant. pub const ZERO_SHA1: Self = Self::Sha1([0u8; SHA1_DIGEST_LEN]); pub fn from_sha1(digest: [u8; SHA1_DIGEST_LEN]) -> Self { diff --git a/crates/radicle/src/storage/refs.rs b/crates/radicle/src/storage/refs.rs index 08d69ce8..639dd5f9 100644 --- a/crates/radicle/src/storage/refs.rs +++ b/crates/radicle/src/storage/refs.rs @@ -177,7 +177,7 @@ impl Refs { let mut buf = String::new(); for (name, oid) in self.0.iter() { - debug_assert_ne!(oid, &Oid::ZERO_SHA1); + debug_assert!(!oid.is_zero()); debug_assert_ne!(name, &SIGREFS_BRANCH.to_ref_string()); buf.push_str(&oid.to_string());