Skip to content

Commit

Permalink
fix clippy error
Browse files Browse the repository at this point in the history
  • Loading branch information
titaneric committed Jan 11, 2025
1 parent ead3dca commit c32e7ba
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions src/format/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ where
Item::Fixed(Internal(InternalFixed { val: InternalInternal::Nanosecond6NoDot })) => 6,
Item::Fixed(Internal(InternalFixed { val: InternalInternal::Nanosecond9NoDot })) => 9,

Check warning on line 291 in src/format/parse.rs

View check run for this annotation

Codecov / codecov/patch

src/format/parse.rs#L290-L291

Added lines #L290 - L291 were not covered by tests
Item::Literal(prefix) => {
prefix.as_bytes().iter().take_while(|&&c| b'0' <= c && c <= b'9').count()
prefix.as_bytes().iter().take_while(|&&c| (b'0'..=b'9').contains(&c)).count()
}
_ => 0,
})
Expand Down Expand Up @@ -404,8 +404,11 @@ where
// Try to consume the number in the non-greedy way.
if max_width == usize::MAX {
let next_size = get_numeric_item_len(next_item).unwrap_or(0);
let numeric_bytes_available =
substr.as_bytes().iter().take_while(|&&c| b'0' <= c && c <= b'9').count();
let numeric_bytes_available = substr
.as_bytes()
.iter()
.take_while(|&&c| (b'0'..=b'9').contains(&c))
.count();
max_width = numeric_bytes_available - next_size;
}
let mut v = try_consume!(scan::number(substr, min_width, max_width));
Expand Down
2 changes: 1 addition & 1 deletion src/format/scan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub(super) fn number(s: &str, min: usize, max: usize) -> ParseResult<(&str, i64)
return Err(TOO_SHORT);
}

if !(min <= max) {
if (min > max) {
return Err(INVALID);
}

Expand Down

0 comments on commit c32e7ba

Please sign in to comment.