From 27ad10c2954185ce5e427ed411fc3d07bc81d21e Mon Sep 17 00:00:00 2001 From: kageru Date: Tue, 26 Sep 2023 14:10:49 +0200 Subject: [PATCH] make try block nicer --- src/parser.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/parser.rs b/src/parser.rs index 836662b..d3d52dc 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -98,7 +98,7 @@ fn values(input: &str) -> IResult<&str, Value> { fn parse_values(input: &str) -> Result { if input.starts_with('/') { - return parse_single_value(input); + parse_single_value(input) } else { let values = input.split('|').map(parse_single_value).collect::, String>>()?; Ok(match values.as_slice() { @@ -111,8 +111,8 @@ fn parse_values(input: &str) -> Result { fn parse_single_value(input: &str) -> Result { Ok(match input.parse() { Ok(n) => Value::Numerical(n), - Err(_) => match try { Value::Regex(Regex::new(&input.strip_prefix('/')?.strip_suffix('/')?.to_lowercase()).ok()?) } { - Some(regex) => regex, + Err(_) => match try { Regex::new(&input.strip_prefix('/')?.strip_suffix('/')?.to_lowercase()).ok()? } { + Some(regex) => Value::Regex(regex), None => Value::String(sanitize(input)?), }, })