halp, i cant write a recursive iterator :3

This commit is contained in:
🪞👃🪞 2025-01-05 03:29:27 +01:00
parent f3fd88a199
commit 140fd22223
10 changed files with 107 additions and 99 deletions

View file

@ -55,4 +55,15 @@ impl<'a> Token<'a> {
}
Ok(("", state))
}
pub fn number (digits: &str) -> usize {
let mut value = 0;
for c in digits.chars() { value = 10 * value + Self::digit(c); }
value
}
pub const fn digit (c: char) -> usize {
match c { '0' => 0, '1' => 1, '2' => 2, '3' => 3, '4' => 4,
'5' => 5, '6' => 6, '7' => 7, '8' => 8, '9' => 9, _ => unreachable!() }
}
}