History

change!: SIZE_OF_SHA1_DIGEST is now private (#279)

Replace it with your own constant derived from `git_hash::Kind::Sha1.len_in_bytes()` or even better, make this value configurable once it's clear how differently sized hashes are used within gits files.

Sebastian Thiel committed 4 years ago

Commit b596fa01 parent 265b8ec1 file · +2 −8Browse files

Unified · Split

git-hash/src/lib.rs+2−8
@@ -49,19 +49,13 @@ pub mod decode { · 48 unmodified lines
4949 type Err = Error;
5050
5151 fn from_str(s: &str) -> Result<Self, Self::Err> {
52− use hex::FromHex;
53− match s.len() {
54− 40 => Ok(ObjectId::Sha1(
55− <[u8; 20]>::from_hex(s).expect("our length check is correct thus we can decode hex"),
56− )),
57− len => Err(Error::InvalidHexEncodingLength(len)),
58− }
52+ Self::from_hex(s.as_bytes())
5953 }
6054 }
6155 }
6256
6357 /// The size of a SHA1 hash digest in bytes
64−pub const SIZE_OF_SHA1_DIGEST: usize = 20;
58+const SIZE_OF_SHA1_DIGEST: usize = 20;
6559
6660 /// Denotes the kind of function to produce a `Id`
6761 #[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]