diff --git a/rslib/src/search/parser.rs b/rslib/src/search/parser.rs index 1123cd701..e4f4cdb93 100644 --- a/rslib/src/search/parser.rs +++ b/rslib/src/search/parser.rs @@ -18,7 +18,6 @@ use nom::{ use regex::{Captures, Regex}; use std::{borrow::Cow, num}; - struct ParseError {} impl From for ParseError { @@ -221,7 +220,7 @@ fn search_node_for_text(s: &str) -> ParseResult { fn unquoted_term(s: &str) -> IResult<&str, Node> { map_res( verify( - escaped(is_not("\"() \u{3000}\\"), '\\', none_of(" \u{3000}")), + escaped(is_not("\"() \u{3000}\\"), '\\', none_of(" \u{3000}")), |s: &str| !s.is_empty(), ), |text: &str| -> ParseResult { @@ -259,7 +258,7 @@ fn partially_quoted_term(s: &str) -> IResult<&str, Node> { map_res( separated_pair( verify( - escaped(is_not("\"(): \u{3000}\\"), '\\', none_of(": \u{3000}")), + escaped(is_not("\"(): \u{3000}\\"), '\\', none_of(": \u{3000}")), |s: &str| !s.is_empty(), ), char(':'), @@ -472,19 +471,17 @@ fn unescape_to_glob(txt: &str) -> ParseResult> { lazy_static! { static ref RE: Regex = Regex::new(r"\\.|[*%]").unwrap(); } - Ok(RE.replace_all(&txt, |caps: &Captures| { - match &caps[0] { - r"\\" => r"\\", - "\\\"" => "\"", - r"\:" => ":", - r"\*" => "*", - r"\_" => r"\_", - r"\(" => "(", - r"\)" => ")", - "*" => "%", - "%" => r"\%", - _ => unreachable!(), - } + Ok(RE.replace_all(&txt, |caps: &Captures| match &caps[0] { + r"\\" => r"\\", + "\\\"" => "\"", + r"\:" => ":", + r"\*" => "*", + r"\_" => r"\_", + r"\(" => "(", + r"\)" => ")", + "*" => "%", + "%" => r"\%", + _ => unreachable!(), })) } } @@ -512,12 +509,12 @@ fn unescape_to_custom_re<'a>(txt: &'a str, wildcard: &str) -> ParseResult