From 2fe83cabf1a4b61e1f1f31847a593a2e1bcc9674 Mon Sep 17 00:00:00 2001 From: Daniel Hofstetter Date: Mon, 27 Jan 2025 10:53:08 +0100 Subject: [PATCH] Adapt to API changes in nom 8.0.0 --- src/parse_timestamp.rs | 10 +++++----- src/parse_weekday.rs | 5 +++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/parse_timestamp.rs b/src/parse_timestamp.rs index 732558d..6e5b20d 100644 --- a/src/parse_timestamp.rs +++ b/src/parse_timestamp.rs @@ -10,8 +10,7 @@ use nom::character::complete::{char, digit1}; use nom::combinator::all_consuming; use nom::multi::fold_many0; use nom::sequence::preceded; -use nom::sequence::tuple; -use nom::{self, IResult}; +use nom::{self, IResult, Parser}; #[derive(Debug, PartialEq)] pub enum ParseTimestampError { @@ -55,7 +54,7 @@ pub(crate) fn parse_timestamp(s: &str) -> Result { let res: IResult<&str, (char, &str)> = all_consuming(preceded( char('@'), - tuple(( + ( // Note: to stay compatible with gnu date this code allows // multiple + and - and only considers the last one fold_many0( @@ -67,8 +66,9 @@ pub(crate) fn parse_timestamp(s: &str) -> Result { |_, c| c, ), digit1, - )), - ))(s); + ), + )) + .parse(s); let (_, (sign, number_str)) = res?; diff --git a/src/parse_weekday.rs b/src/parse_weekday.rs index d61aca7..58e3180 100644 --- a/src/parse_weekday.rs +++ b/src/parse_weekday.rs @@ -4,7 +4,7 @@ use chrono::Weekday; use nom::branch::alt; use nom::bytes::complete::tag; use nom::combinator::value; -use nom::{self, IResult}; +use nom::{self, IResult, Parser}; // Helper macro to simplify tag matching macro_rules! tag_match { @@ -25,7 +25,8 @@ pub(crate) fn parse_weekday(s: &str) -> Option { tag_match!(Weekday::Fri, "friday", "fri"), tag_match!(Weekday::Sat, "saturday", "sat"), tag_match!(Weekday::Sun, "sunday", "sun"), - )))(s); + ))) + .parse(s); match parse_result { Ok((_, weekday)) => Some(weekday),