mirror of
https://github.com/uutils/findutils.git
synced 2026-06-10 15:48:30 -07:00
Fix some problems reported by clippy
This commit is contained in:
@@ -35,11 +35,11 @@ impl Matcher for AndMatcher {
|
||||
/// place. If the nth sub-matcher returns false, then we immediately return
|
||||
/// and don't make any further calls.
|
||||
fn matches(&self, dir_entry: &DirEntry, matcher_io: &mut MatcherIO) -> bool {
|
||||
self.submatchers.iter().all(|ref x| x.matches(dir_entry, matcher_io))
|
||||
self.submatchers.iter().all(|x| x.matches(dir_entry, matcher_io))
|
||||
}
|
||||
|
||||
fn has_side_effects(&self) -> bool {
|
||||
self.submatchers.iter().any(|ref x| x.has_side_effects())
|
||||
self.submatchers.iter().any(|x| x.has_side_effects())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,11 +91,11 @@ impl Matcher for OrMatcher {
|
||||
/// place. If the nth sub-matcher returns true, then we immediately return
|
||||
/// and don't make any further calls.
|
||||
fn matches(&self, dir_entry: &DirEntry, matcher_io: &mut MatcherIO) -> bool {
|
||||
self.submatchers.iter().any(|ref x| x.matches(dir_entry, matcher_io))
|
||||
self.submatchers.iter().any(|x| x.matches(dir_entry, matcher_io))
|
||||
}
|
||||
|
||||
fn has_side_effects(&self) -> bool {
|
||||
self.submatchers.iter().any(|ref x| x.has_side_effects())
|
||||
self.submatchers.iter().any(|x| x.has_side_effects())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,10 +142,10 @@ impl OrMatcherBuilder {
|
||||
|
||||
|
||||
/// This matcher contains a collection of other matchers. In contrast to
|
||||
/// OrMatcher and AndMatcher, all the submatcher objects are called regardless
|
||||
/// of the results of previous submatchers. This is primarily used for
|
||||
/// submatchers with side-effects. For such sub-matchers the side effects occur
|
||||
/// in the same order as the sub-matchers were pushed into the collection.
|
||||
/// `OrMatcher` and `AndMatcher`, all the submatcher objects are called
|
||||
/// regardless of the results of previous submatchers. This is primarily used
|
||||
/// for submatchers with side-effects. For such sub-matchers the side effects
|
||||
/// occur in the same order as the sub-matchers were pushed into the collection.
|
||||
pub struct ListMatcher {
|
||||
submatchers: Vec<Box<Matcher>>,
|
||||
}
|
||||
@@ -162,14 +162,14 @@ impl Matcher for ListMatcher {
|
||||
/// Returns the result of the call to the final submatcher
|
||||
fn matches(&self, dir_entry: &DirEntry, matcher_io: &mut MatcherIO) -> bool {
|
||||
let mut rc = false;
|
||||
for ref matcher in &self.submatchers {
|
||||
for matcher in &self.submatchers {
|
||||
rc = matcher.matches(dir_entry, matcher_io);
|
||||
}
|
||||
rc
|
||||
}
|
||||
|
||||
fn has_side_effects(&self) -> bool {
|
||||
self.submatchers.iter().any(|ref x| x.has_side_effects())
|
||||
self.submatchers.iter().any(|x| x.has_side_effects())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -90,7 +90,7 @@ impl ComparableValue {
|
||||
}
|
||||
|
||||
|
||||
/// Builds a single AndMatcher containing the Matcher objects corresponding
|
||||
/// Builds a single `AndMatcher` containing the Matcher objects corresponding
|
||||
/// to the passed in predicate arguments.
|
||||
pub fn build_top_level_matcher(args: &[&str],
|
||||
config: &mut Config)
|
||||
@@ -107,13 +107,13 @@ pub fn build_top_level_matcher(args: &[&str],
|
||||
Ok(top_level_matcher)
|
||||
}
|
||||
|
||||
/// Helper function for build_matcher_tree
|
||||
/// Helper function for `build_matcher_tree`.
|
||||
fn are_more_expressions(args: &[&str], index: usize) -> bool {
|
||||
(index < args.len() - 1) && args[index + 1] != ")"
|
||||
}
|
||||
|
||||
fn convert_arg_to_number(option_name: &str, value_as_string: &str) -> Result<usize, Box<Error>> {
|
||||
return match value_as_string.parse::<usize>() {
|
||||
match value_as_string.parse::<usize>() {
|
||||
Ok(val) => Ok(val),
|
||||
_ => {
|
||||
Err(From::from(format!("Expected a positive decimal integer argument to {}, but got \
|
||||
@@ -121,7 +121,7 @@ fn convert_arg_to_number(option_name: &str, value_as_string: &str) -> Result<usi
|
||||
option_name,
|
||||
value_as_string)))
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
fn convert_arg_to_comparable_value(option_name: &str,
|
||||
|
||||
@@ -11,7 +11,7 @@ use walkdir::DirEntry;
|
||||
use find::matchers::{Matcher, MatcherIO};
|
||||
|
||||
/// This matcher makes a case-sensitive comparison of the name against a
|
||||
/// shell wildcard pattern. See glob::Pattern for details on the exact
|
||||
/// shell wildcard pattern. See `glob::Pattern` for details on the exact
|
||||
/// syntax.
|
||||
pub struct NameMatcher {
|
||||
pattern: Pattern,
|
||||
@@ -30,7 +30,7 @@ impl NameMatcher {
|
||||
|
||||
impl Matcher for NameMatcher {
|
||||
fn matches(&self, file_info: &DirEntry, _: &mut MatcherIO) -> bool {
|
||||
return self.pattern.matches(file_info.file_name().to_string_lossy().as_ref());
|
||||
self.pattern.matches(file_info.file_name().to_string_lossy().as_ref())
|
||||
}
|
||||
|
||||
fn has_side_effects(&self) -> bool {
|
||||
@@ -39,7 +39,7 @@ impl Matcher for NameMatcher {
|
||||
}
|
||||
|
||||
/// This matcher makes a case-insensitive comparison of the name against a
|
||||
/// shell wildcard pattern. See glob::Pattern for details on the exact
|
||||
/// shell wildcard pattern. See `glob::Pattern` for details on the exact
|
||||
/// syntax.
|
||||
pub struct CaselessNameMatcher {
|
||||
pattern: Pattern,
|
||||
@@ -58,8 +58,8 @@ impl CaselessNameMatcher {
|
||||
|
||||
impl super::Matcher for CaselessNameMatcher {
|
||||
fn matches(&self, file_info: &DirEntry, _: &mut MatcherIO) -> bool {
|
||||
return self.pattern
|
||||
.matches(file_info.file_name().to_string_lossy().to_lowercase().as_ref());
|
||||
self.pattern
|
||||
.matches(file_info.file_name().to_string_lossy().to_lowercase().as_ref())
|
||||
}
|
||||
|
||||
fn has_side_effects(&self) -> bool {
|
||||
|
||||
@@ -24,7 +24,7 @@ impl PruneMatcher {
|
||||
impl Matcher for PruneMatcher {
|
||||
fn matches(&self, _: &DirEntry, matcher_io: &mut MatcherIO) -> bool {
|
||||
matcher_io.mark_current_dir_to_be_skipped();
|
||||
return true;
|
||||
true
|
||||
}
|
||||
|
||||
fn has_side_effects(&self) -> bool {
|
||||
|
||||
+1
-1
@@ -72,7 +72,7 @@ struct ParsedInfo {
|
||||
config: Config,
|
||||
}
|
||||
|
||||
/// Function to generate a ParsedInfo from the strings supplied on the command-line.
|
||||
/// Function to generate a `ParsedInfo` from the strings supplied on the command-line.
|
||||
fn parse_args(args: &[&str]) -> Result<ParsedInfo, Box<Error>> {
|
||||
let mut paths = vec![];
|
||||
let mut i = 0;
|
||||
|
||||
Reference in New Issue
Block a user