const_str/
ascii.rs

1pub const fn num_to_hex_digit(x: u8) -> u8 {
2    match x {
3        0..=9 => b'0' + x,
4        10..=15 => b'a' + (x - 10),
5        _ => panic!("invalid hex number"),
6    }
7}
8
9pub const fn num_from_dec_digit(d: u8) -> u8 {
10    match d {
11        b'0'..=b'9' => d - b'0',
12        _ => panic!("invalid dec digit"),
13    }
14}