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.
Unified · Split
| @@ -49,19 +49,13 @@ pub mod decode { · 48 unmodified lines | ||
| 49 | 49 | type Err = Error; |
| 50 | 50 | |
| 51 | 51 | 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()) | |
| 59 | 53 | } |
| 60 | 54 | } |
| 61 | 55 | } |
| 62 | 56 | |
| 63 | 57 | /// 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; | |
| 65 | 59 | |
| 66 | 60 | /// Denotes the kind of function to produce a `Id` |
| 67 | 61 | #[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)] |