From 2e2bdac00092f8fcb96283da697a7a820a8c8978 Mon Sep 17 00:00:00 2001 From: Daniel Date: Fri, 12 Nov 2021 14:08:35 +0100 Subject: Minor code smell fixes --- src/fexpr/grammar.lalrpop | 19 +++++-------------- src/fexpr/mod.rs | 13 ++++++------- 2 files changed, 11 insertions(+), 21 deletions(-) (limited to 'src/fexpr') 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 = { =>? 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 = { =>? 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 = { =>? w.parse().map_err(|_| ParseError::User { error: FError { location: l, - data: w.into(), - kind: FErrorKind::InvalidBoss, + kind: FErrorKind::Boss, } }), =>? 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 = { =>? 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 = { .map_err(|error| ParseError::User { error: FError { location: l, - data: d.into(), kind: error.into(), } }) @@ -180,7 +172,6 @@ Date: DateTime = { .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. -- cgit v1.2.3