diff options
-rw-r--r-- | src/fexpr/grammar.lalrpop | 19 | ||||
-rw-r--r-- | src/fexpr/mod.rs | 13 | ||||
-rw-r--r-- | src/main.rs | 8 | ||||
-rw-r--r-- | src/output/sorting.rs | 2 |
4 files changed, 16 insertions, 26 deletions
diff --git a/src/fexpr/grammar.lalrpop b/src/fexpr/grammar.lalrpop index 6333783..ce78396 100644 --- a/src/fexpr/grammar.lalrpop +++ b/src/fexpr/grammar.lalrpop @@ -102,7 +102,6 @@ Regex: Regex = { .map_err(|error| ParseError::User { error: FError { location: l, - data: s.to_string(), kind: error.into(), } }), @@ -112,7 +111,6 @@ Regex: Regex = { .map_err(|error| ParseError::User { error: FError { location: l, - data: s.to_string(), kind: error.into(), } }), @@ -122,8 +120,7 @@ FightOutcome: FightOutcome = { <l:@L> <w:word> =>? w.parse().map_err(|_| ParseError::User { error: FError { location: l, - data: w.into(), - kind: FErrorKind::InvalidFightOutcome, + kind: FErrorKind::FightOutcome, } }), } @@ -132,8 +129,7 @@ Weekday: Weekday = { <l:@L> <w:word> =>? w.parse().map_err(|_| ParseError::User { error: FError { location: l, - data: w.into(), - kind: FErrorKind::InvalidWeekday, + kind: FErrorKind::Weekday, } }), } @@ -142,16 +138,14 @@ Encounter: Encounter = { <l:@L> <w:word> =>? w.parse().map_err(|_| ParseError::User { error: FError { location: l, - data: w.into(), - kind: FErrorKind::InvalidBoss, + kind: FErrorKind::Boss, } }), <l:@L> <s:string> =>? s[1..s.len() -1].parse().map_err(|_| ParseError::User { error: FError { location: l, - data: s.into(), - kind: FErrorKind::InvalidBoss, + kind: FErrorKind::Boss, } }), } @@ -160,8 +154,7 @@ PlayerClass: PlayerClass = { <l:@L> <w:word> =>? w.parse().map_err(|_| ParseError::User { error: FError { location: l, - data: w.into(), - kind: FErrorKind::InvalidClass, + kind: FErrorKind::Class, } }), } @@ -171,7 +164,6 @@ Date: DateTime<Utc> = { .map_err(|error| ParseError::User { error: FError { location: l, - data: d.into(), kind: error.into(), } }) @@ -180,7 +172,6 @@ Date: DateTime<Utc> = { .map_err(|error| ParseError::User { error: FError { location: l, - data: d.into(), kind: error.into(), } }) diff --git a/src/fexpr/mod.rs b/src/fexpr/mod.rs index 90242f2..0fe2acf 100644 --- a/src/fexpr/mod.rs +++ b/src/fexpr/mod.rs @@ -22,7 +22,6 @@ lalrpop_mod!(#[allow(clippy::all)] pub grammar, "/fexpr/grammar.rs"); #[derive(Debug)] pub struct FError { location: usize, - data: String, kind: FErrorKind, } @@ -41,17 +40,17 @@ impl error::Error for FError { #[derive(Debug, Error)] pub enum FErrorKind { #[error("invalid regular expression: {0}")] - InvalidRegex(#[from] regex::Error), + Regex(#[from] regex::Error), #[error("invalid fight outcome")] - InvalidFightOutcome, + FightOutcome, #[error("invalid weekday")] - InvalidWeekday, + Weekday, #[error("invalid timestamp: {0}")] - InvalidTimestamp(#[from] chrono::format::ParseError), + Timestamp(#[from] chrono::format::ParseError), #[error("invalid boss name")] - InvalidBoss, + Boss, #[error("invalid class name")] - InvalidClass, + Class, } /// Shortcut to create a new parser and parse the given input. diff --git a/src/main.rs b/src/main.rs index 256de97..27ad285 100644 --- a/src/main.rs +++ b/src/main.rs @@ -155,11 +155,11 @@ impl Opt { return Ok(filter); } } - return Ok(maybe_filter?); + return maybe_filter; } let expr_string = fexpr::requote(&self.expression); - Ok(build_filter(&expr_string)?) + build_filter(&expr_string) } } @@ -369,7 +369,7 @@ fn single(opt: &Opt) -> Result<bool> { .unwrap_or(false); search_file(path, is_zip, &*filter).map(|r| r.is_some()) } else { - grep(&opt, &*filter) + grep(opt, &*filter) } } @@ -393,7 +393,7 @@ fn repl(opt: &Opt) -> Result<()> { let parsed = build_filter(&line); INTERRUPTED.store(false, Ordering::Relaxed); match parsed { - Ok(filter) => grep(&opt, &*filter).map(|_| ())?, + Ok(filter) => grep(opt, &*filter).map(|_| ())?, Err(err) => display_error(&err), } } diff --git a/src/output/sorting.rs b/src/output/sorting.rs index 2ed746a..234d804 100644 --- a/src/output/sorting.rs +++ b/src/output/sorting.rs @@ -95,7 +95,7 @@ impl FromStr for Sorting { type Err = InvalidComponent; fn from_str(s: &str) -> Result<Self, Self::Err> { - if s == "" { + if s.is_empty() { return Ok(Sorting::default()); } let parts = s.split(','); |