Skip to content

Commit

Permalink
chore: Replace manual digit parsing with character::complete::u8
Browse files Browse the repository at this point in the history
  • Loading branch information
leo91000 committed Dec 12, 2022
1 parent 579e34d commit f5d680d
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions crates/crontab_parser/src/nom_crontab_timer.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use nom::{
branch::alt,
character::complete::{char, digit1},
combinator::{map, map_res, opt, recognize, verify},
character::complete::{self, char},
combinator::{map, opt, verify},
multi::separated_list1,
sequence::{preceded, separated_pair, terminated},
IResult,
Expand All @@ -12,11 +12,7 @@ use crate::types::{CrontabPart, CrontabTimer, CrontabValue};
/// Attempts to parse a number with crontab part boundaries
fn crontab_number<'a>(part: &CrontabPart) -> impl Fn(&'a str) -> IResult<&'a str, u8> {
let (min, max) = part.boundaries();
move |input| {
verify(map_res(recognize(digit1), str::parse::<u8>), |v| {
v >= &min && v <= &max
})(input)
}
move |input| verify(complete::u8, |v| v >= &min && v <= &max)(input)
}

/// Attempts to parse a range with crontab part boundaries
Expand Down

0 comments on commit f5d680d

Please sign in to comment.