diff --git a/src/error.rs b/src/error.rs index 31ea54c..ca14c5e 100644 --- a/src/error.rs +++ b/src/error.rs @@ -200,6 +200,6 @@ impl fmt::Display for ParsingErrorKind { } } -fn escape_ascii(path: &Path) -> EscapeAscii { +fn escape_ascii(path: &Path) -> EscapeAscii<'_> { path.as_os_str().as_encoded_bytes().escape_ascii() } diff --git a/src/function/parse.rs b/src/function/parse.rs index ebb39c0..e6ace89 100644 --- a/src/function/parse.rs +++ b/src/function/parse.rs @@ -39,11 +39,11 @@ fn build_regex(input: &str) -> Result<(&'static str, Regex), regex::Error> { .map(|r| ("", r)) } -fn parse_regex(input: &str) -> ParsingResult { +fn parse_regex(input: &str) -> ParsingResult<'_, Regex> { build_regex(input).map_err(|e| Err::Failure(ParsingErrorKind::from(e).at(input))) } -fn parse_anchored_regex(input: &str) -> ParsingResult { +fn parse_anchored_regex(input: &str) -> ParsingResult<'_, Regex> { build_regex(&format!("^{input}$")) .map_err(|e| Err::Failure(ParsingErrorKind::from(e).at(input))) } @@ -56,13 +56,13 @@ fn parse_path(input: &str) -> IResult<&str, PathBuf> { .parse(input) } -fn parse_size(input: &str) -> ParsingResult { +fn parse_size(input: &str) -> ParsingResult<'_, u64> { str::parse(input) .map(|c| ("", c)) .map_err(|e| Err::Failure(ParsingErrorKind::from(e).at(input))) } -fn parse_file_size_args(input: &str) -> ParsingResult<(PathBuf, u64)> { +fn parse_file_size_args(input: &str) -> ParsingResult<'_, (PathBuf, u64)> { let mut parser = ( map_err(parse_path), map_err(whitespace(tag(","))), @@ -82,7 +82,7 @@ fn parse_version(input: &str) -> IResult<&str, String> { .parse(input) } -fn parse_version_args(input: &str) -> ParsingResult<(PathBuf, String, ComparisonOperator)> { +fn parse_version_args(input: &str) -> ParsingResult<'_, (PathBuf, String, ComparisonOperator)> { let parser = ( parse_path, whitespace(tag(",")), @@ -98,7 +98,7 @@ fn parse_version_args(input: &str) -> ParsingResult<(PathBuf, String, Comparison fn parse_filename_version_args( input: &str, -) -> ParsingResult<(PathBuf, Regex, String, ComparisonOperator)> { +) -> ParsingResult<'_, (PathBuf, Regex, String, ComparisonOperator)> { let mut parser = ( delimited(map_err(tag("\"")), parse_regex_path, map_err(tag("\""))), map_err(whitespace(tag(","))), @@ -118,7 +118,7 @@ fn parse_filename_version_args( Ok((remaining_input, (path, regex, version, comparator))) } -fn parse_description_contains_args(input: &str) -> ParsingResult<(PathBuf, Regex)> { +fn parse_description_contains_args(input: &str) -> ParsingResult<'_, (PathBuf, Regex)> { let mut parser = ( map_err(parse_path), map_err(whitespace(tag(","))), @@ -134,13 +134,13 @@ fn parse_description_contains_args(input: &str) -> ParsingResult<(PathBuf, Regex Ok((remaining_input, (path, regex))) } -fn parse_crc(input: &str) -> ParsingResult { +fn parse_crc(input: &str) -> ParsingResult<'_, u32> { u32::from_str_radix(input, 16) .map(|c| ("", c)) .map_err(|e| Err::Failure(ParsingErrorKind::from(e).at(input))) } -fn parse_checksum_args(input: &str) -> ParsingResult<(PathBuf, u32)> { +fn parse_checksum_args(input: &str) -> ParsingResult<'_, (PathBuf, u32)> { let mut parser = ( map_err(parse_path), map_err(whitespace(tag(","))), @@ -152,7 +152,7 @@ fn parse_checksum_args(input: &str) -> ParsingResult<(PathBuf, u32)> { Ok((remaining_input, (path, crc))) } -fn parse_non_regex_path(input: &str) -> ParsingResult { +fn parse_non_regex_path(input: &str) -> ParsingResult<'_, PathBuf> { let (remaining_input, path) = map(is_not(INVALID_NON_REGEX_PATH_CHARS), |path: &str| { PathBuf::from(path) }) @@ -163,7 +163,7 @@ fn parse_non_regex_path(input: &str) -> ParsingResult { /// Parse a string that is a path where the last component is a regex string /// that may contain characters that are invalid in paths but valid in regex. -fn parse_regex_path(input: &str) -> ParsingResult<(PathBuf, Regex)> { +fn parse_regex_path(input: &str) -> ParsingResult<'_, (PathBuf, Regex)> { let (remaining_input, string) = is_not(INVALID_REGEX_PATH_CHARS)(input)?; if string.ends_with('/') { @@ -181,13 +181,13 @@ fn parse_regex_path(input: &str) -> ParsingResult<(PathBuf, Regex)> { Ok((remaining_input, (parent_path, regex))) } -fn parse_regex_filename(input: &str) -> ParsingResult { +fn parse_regex_filename(input: &str) -> ParsingResult<'_, Regex> { map_parser(is_not(INVALID_REGEX_PATH_CHARS), parse_anchored_regex).parse(input) } impl Function { #[expect(clippy::too_many_lines)] - pub fn parse(input: &str) -> ParsingResult { + pub fn parse(input: &str) -> ParsingResult<'_, Function> { alt(( map( delimited( diff --git a/src/function/version.rs b/src/function/version.rs index 20ce68c..8ff56a9 100644 --- a/src/function/version.rs +++ b/src/function/version.rs @@ -163,11 +163,11 @@ impl Version { } } -fn get_pe_version_info(bytes: &[u8]) -> Result { +fn get_pe_version_info(bytes: &[u8]) -> Result, FindError> { get_pe_resources(bytes)?.version_info() } -fn get_pe_resources(bytes: &[u8]) -> Result { +fn get_pe_resources(bytes: &[u8]) -> Result, pelite::Error> { use pelite::pe64; match pe64::PeFile::from_bytes(bytes) { Ok(file) => { diff --git a/src/lib.rs b/src/lib.rs index 771c062..aca7ee5 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -134,7 +134,7 @@ impl State { pub fn set_cached_crcs>( &mut self, plugin_crcs: &[(T, u32)], - ) -> Result<(), PoisonError>>> { + ) -> Result<(), PoisonError>>> { let mut writer = self.crc_cache.write().unwrap_or_else(|mut e| { **e.get_mut() = HashMap::new(); self.crc_cache.clear_poison(); @@ -153,7 +153,7 @@ impl State { pub fn clear_condition_cache( &mut self, - ) -> Result<(), PoisonError>>> { + ) -> Result<(), PoisonError>>> { let mut writer = self.condition_cache.write().unwrap_or_else(|mut e| { **e.get_mut() = HashMap::new(); self.crc_cache.clear_poison(); @@ -199,7 +199,7 @@ impl str::FromStr for Expression { } } -fn parse_expression(input: &str) -> ParsingResult { +fn parse_expression(input: &str) -> ParsingResult<'_, Expression> { map( separated_list0(map_err(whitespace(tag("or"))), CompoundCondition::parse), Expression, @@ -228,7 +228,7 @@ impl CompoundCondition { Ok(true) } - fn parse(input: &str) -> ParsingResult { + fn parse(input: &str) -> ParsingResult<'_, CompoundCondition> { map( separated_list0(map_err(whitespace(tag("and"))), Condition::parse), CompoundCondition, @@ -262,7 +262,7 @@ impl Condition { } } - fn parse(input: &str) -> ParsingResult { + fn parse(input: &str) -> ParsingResult<'_, Condition> { alt(( map(Function::parse, Condition::Function), map(