Re: [PATCH 05/14] rust: add a hash algorithm abstraction
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 29, 2025, 14:32 UTC
- Message-ID
- <xmqq4irhbwym.fsf@gitster.g>
- In-Reply-To
- <xmqq8qgtbzyi.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 11 quoted lines
>>> 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. > > Perhaps. But the Option/Result was not what I was suprised about. > ... > Perhaps as_mut_slice() side is justifiable (an uninitialized > instance of ObjectID is filled by getting the full self.hash and > filling it, plus filling the algo), but the same explanation would > not apply on the read-only side.
Rethinking, I guess the "why doesn't it fail in the None case?" is exactly the same question as "why Option, not Result?" as you suggested. Sorry for the noise.