From 7df9ff85271403274d0a1d93156899014124f02e Mon Sep 17 00:00:00 2001 From: yuanbohan Date: Tue, 31 Oct 2023 09:34:58 +0800 Subject: [PATCH] fix: clippy --- src/parser/lex.rs | 2 +- src/util/duration.rs | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/parser/lex.rs b/src/parser/lex.rs index 5181eff..a7eb712 100644 --- a/src/parser/lex.rs +++ b/src/parser/lex.rs @@ -17,7 +17,7 @@ use lrlex::{DefaultLexeme, LRNonStreamingLexer}; use lrpar::Lexeme; use std::fmt::Debug; -const ESCAPE_SYMBOLS: &str = r#"abfnrtv\01234567xuU"#; +const ESCAPE_SYMBOLS: &str = r"abfnrtv\01234567xuU"; const STRING_SYMBOLS: &str = r#"'"`"#; pub(crate) type LexemeType = DefaultLexeme; diff --git a/src/util/duration.rs b/src/util/duration.rs index 7315784..32d9f17 100644 --- a/src/util/duration.rs +++ b/src/util/duration.rs @@ -89,11 +89,9 @@ pub fn parse_duration(ds: &str) -> Result { .and_then(|cap| cap.as_str().parse::().ok()) .and_then(|v| duration.checked_mul(v)) }) - .fold(Ok(Duration::ZERO), |acc, x| { - acc.and_then(|d| { - d.checked_add(x.unwrap_or(Duration::ZERO)) - .ok_or_else(|| "duration overflowed".into()) - }) + .try_fold(Duration::ZERO, |acc, x| { + acc.checked_add(x.unwrap_or(Duration::ZERO)) + .ok_or_else(|| "duration overflowed".into()) }); if matches!(dur, Ok(d) if d == Duration::ZERO) {