find: fix clippy::redundant_closure_for_method_calls

This commit is contained in:
Sylvestre Ledru
2026-06-08 22:48:45 +02:00
parent a2c75f94ca
commit a80620c88f
5 changed files with 18 additions and 10 deletions
+4 -4
View File
@@ -174,9 +174,9 @@ impl From<walkdir::Error> for WalkError {
impl From<&walkdir::Error> for WalkError {
fn from(e: &walkdir::Error) -> Self {
Self {
path: e.path().map(|p| p.to_owned()),
path: e.path().map(std::borrow::ToOwned::to_owned),
depth: Some(e.depth()),
raw: e.io_error().and_then(|e| e.raw_os_error()),
raw: e.io_error().and_then(std::io::Error::raw_os_error),
}
}
}
@@ -279,7 +279,7 @@ impl WalkEntry {
// Path::file_name() only works if the last component is normal
path.components()
.next_back()
.map(|c| c.as_os_str())
.map(std::path::Component::as_os_str)
.unwrap_or_else(|| path.as_os_str())
}
Entry::WalkDir(ent) => ent.file_name(),
@@ -311,7 +311,7 @@ impl WalkEntry {
Entry::Explicit(_, _) => Ok(self.get_metadata()?),
Entry::WalkDir(ent) => Ok(ent.metadata()?),
});
result.as_ref().map_err(|e| e.clone())
result.as_ref().map_err(std::clone::Clone::clone)
}
/// Get the file type of this entry.
+2 -2
View File
@@ -1032,10 +1032,10 @@ fn parse_files0_args(config: &mut Config) -> Result<(), Box<dyn Error>> {
let mut string_segments: Vec<String> = buffer_split
.iter()
.filter_map(|s| std::str::from_utf8(s).ok())
.map(|s| s.to_string())
.map(std::string::ToString::to_string)
.collect();
// empty starting point checker
if string_segments.iter().any(|s| s.is_empty()) {
if string_segments.iter().any(std::string::String::is_empty) {
eprintln!("find: invalid zero-length file name");
// remove the empty ones so as to avoid file not found error
string_segments.retain(|s| !s.is_empty());
+1 -1
View File
@@ -237,7 +237,7 @@ fn process_dir(
Ok(entry) => {
let mut matcher_io = matchers::MatcherIO::new(deps);
let new_dir = entry.path().parent().map(|x| x.to_path_buf());
let new_dir = entry.path().parent().map(std::path::Path::to_path_buf);
if new_dir != current_dir {
if let Some(dir) = current_dir.take() {
matcher.finished_dir(dir.as_path(), &mut matcher_io);
+1 -1
View File
@@ -448,7 +448,7 @@ impl Iterator for DbReader {
.take(self.prefix as usize)
.collect::<Vec<_>>()
});
if (prefix.as_ref().map(|v| v.len()).unwrap_or(0) as isize) < size {
if (prefix.as_ref().map(std::vec::Vec::len).unwrap_or(0) as isize) < size {
return Some(Err(Error::InvalidDb(
self.path.to_string_lossy().to_string(),
)));
+10 -2
View File
@@ -47,7 +47,11 @@ impl From<ArgMatches> for Config {
.unwrap_or_else(|| vec![PathBuf::from("/")]),
net_paths: value
.get_one::<String>("netpaths")
.map(|s| s.split_whitespace().map(|s| s.to_owned()).collect())
.map(|s| {
s.split_whitespace()
.map(std::borrow::ToOwned::to_owned)
.collect()
})
.unwrap_or_default(),
prune_paths: value
.get_one::<String>("prunepaths")
@@ -60,7 +64,11 @@ impl From<ArgMatches> for Config {
}),
prune_fs: value
.get_one::<String>("prunefs")
.map(|s| s.split_whitespace().map(|s| s.to_owned()).collect())
.map(|s| {
s.split_whitespace()
.map(std::borrow::ToOwned::to_owned)
.collect()
})
.unwrap_or_else(|| {
["nfs", "NFS", "proc"]
.into_iter()