From: Ezekiel Newren Date: Tue, 28 Oct 2025 20:03:11 GMT Subject: Re: [PATCH 05/14] rust: add a hash algorithm abstraction Message-ID: In-Reply-To: On Tue, Oct 28, 2025 at 2:00 PM Junio C Hamano wrote: > > "brian m. carlson" writes: > > > +#[allow(dead_code)] > > +impl ObjectID { > > + pub fn as_slice(&self) -> &[u8] { > > + match HashAlgorithm::from_u32(self.algo) { > > + Some(algo) => &self.hash[0..algo.raw_len()], > > + None => &self.hash, > > + } > > + } > > + > > + pub fn as_mut_slice(&mut self) -> &mut [u8] { > > + match HashAlgorithm::from_u32(self.algo) { > > + Some(algo) => &mut self.hash[0..algo.raw_len()], > > + None => &mut self.hash, > > + } > > + } > > +} > > These cases for "None" surprised me a bit; I would have expected us > to error out when given an algorithm we do not recognise. I think _Result_ would be more appropriate here.