simplify eat_digits

This commit is contained in:
klensy 2021-02-19 18:47:22 +03:00
parent 78e22069d0
commit ec09d7fc8b

View File

@ -80,11 +80,8 @@ pub fn parse_decimal(s: &str) -> ParseResult<'_> {
/// Carves off decimal digits up to the first non-digit character. /// Carves off decimal digits up to the first non-digit character.
fn eat_digits(s: &[u8]) -> (&[u8], &[u8]) { fn eat_digits(s: &[u8]) -> (&[u8], &[u8]) {
let mut i = 0; let pos = s.iter().position(|c| !c.is_ascii_digit()).unwrap_or(s.len());
while i < s.len() && b'0' <= s[i] && s[i] <= b'9' { s.split_at(pos)
i += 1;
}
(&s[..i], &s[i..])
} }
/// Exponent extraction and error checking. /// Exponent extraction and error checking.