diff --git a/Cargo.toml b/Cargo.toml index d96a0c0..99aa901 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "duration-str" -version = "0.11.0" +version = "0.11.1" authors = ["baoyachi "] edition = "2021" description = "duration string parser" diff --git a/benches/parser_benchmark.rs b/benches/parser_benchmark.rs index 77cfe03..ab4dd85 100644 --- a/benches/parser_benchmark.rs +++ b/benches/parser_benchmark.rs @@ -12,16 +12,18 @@ fn parse_duration() { fn impeccable_duration() { let input = "2h 37m"; - ( - digit1::<_, ContextError>.try_map(str::parse::), + let duration = ( + digit1::<_, ContextError>.try_map(str::parse::), literal('h').value(3600), multispace0, - digit1.try_map(str::parse::), + digit1.try_map(str::parse::), literal('m').value(60), ) .map(|(hour, h_unit, _, min, min_unit)| hour * h_unit + min * min_unit) + .map(|seconds| Duration::new(seconds, 0)) .parse(input) .unwrap(); + assert_eq!(duration, Duration::new(9420, 0)) } pub fn duration_str_benchmark(c: &mut Criterion) {