+
+ # `self` as a hexdigit to its byte value
+ #
+ # ~~~nit
+ # intrude import core::bytes
+ # assert 0x39u8.hexdigit_to_byteval == 0x09u8
+ # assert 0x43u8.hexdigit_to_byteval == 0x0Cu8
+ # ~~~
+ #
+ # REQUIRE: `self.is_valid_hexdigit`
+ private fun hexdigit_to_byteval: Byte do
+ if self >= 0x30u8 and self <= 0x39u8 then
+ return self - 0x30u8
+ else if self >= 0x41u8 and self <= 0x46u8 then
+ return self - 0x37u8
+ else if self >= 0x61u8 and self <= 0x66u8 then
+ return self - 0x57u8
+ end
+ # Happens only if the requirement is not met.
+ # i.e. this abort is here to please the compiler
+ abort
+ end