Skip to content

Commit

Permalink
scan.rs clippy warning, prefer c.is_ascii_digit
Browse files Browse the repository at this point in the history
Clippy warning during CI stage "lint"

    error: manual check for common ascii range

Prefer `char::is_ascii_digit()`.
  • Loading branch information
jtmoon79 committed Mar 14, 2023
1 parent 62bb826 commit f23034b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/format/scan.rs
Expand Up @@ -48,7 +48,7 @@ pub(super) fn number(s: &str, min: usize, max: usize) -> ParseResult<(&str, i64)
let mut n = 0i64;
for (i, c) in bytes.iter().take(max).cloned().enumerate() {
// cloned() = copied()
if !(b'0'..=b'9').contains(&c) {
if !c.is_ascii_digit() {
if i < min {
return Err(INVALID);
} else {
Expand Down Expand Up @@ -79,7 +79,7 @@ pub(super) fn nanosecond(s: &str) -> ParseResult<(&str, i64)> {
let v = v.checked_mul(SCALE[consumed]).ok_or(OUT_OF_RANGE)?;

// if there are more than 9 digits, skip next digits.
let s = s.trim_left_matches(|c: char| ('0'..='9').contains(&c));
let s = s.trim_left_matches(|c: char| c.is_ascii_digit());

Ok((s, v))
}
Expand Down

0 comments on commit f23034b

Please sign in to comment.