Adapt to API changes in nom 8.0.0

This commit is contained in:
Daniel Hofstetter
2025-01-27 10:53:08 +01:00
parent 94d4112707
commit 2fe83cabf1
2 changed files with 8 additions and 7 deletions
+5 -5
View File
@@ -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<i64, ParseTimestampError> {
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<i64, ParseTimestampError> {
|_, c| c,
),
digit1,
)),
))(s);
),
))
.parse(s);
let (_, (sign, number_str)) = res?;
+3 -2
View File
@@ -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<Weekday> {
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),