interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / vendor / serde_json / src / lexical / digit.rs

18 lines · 444 bytes Raw Blame History
1// Adapted from https://github.com/Alexhuszagh/rust-lexical.
2
3//! Helpers to convert and add digits from characters.
4
5// Convert u8 to digit.
6#[inline]
7pub(crate) fn to_digit(c: u8) -> Option<u32> {
8 (c as char).to_digit(10)
9}
10
11// Add digit to mantissa.
12#[inline]
13pub(crate) fn add_digit(value: u64, digit: u32) -> Option<u64> {
14 match value.checked_mul(10) {
15 None => None,
16 Some(n) => n.checked_add(digit as u64),
17 }
18}