mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
halp, i cant write a recursive iterator :3
This commit is contained in:
parent
f3fd88a199
commit
140fd22223
10 changed files with 107 additions and 99 deletions
|
|
@ -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!() }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue