Fix some clippy warnings

This commit is contained in:
Thayne McCombs 2022-02-28 01:16:42 -07:00 committed by David Peter
parent b29e87ec30
commit 6e5c8d9c20
3 changed files with 5 additions and 11 deletions

View File

@ -5,13 +5,13 @@ use crate::filesystem::strip_current_dir;
/// Removes the parent component of the path
pub fn basename(path: &Path) -> &OsStr {
path.file_name().unwrap_or_else(|| path.as_os_str())
path.file_name().unwrap_or(path.as_os_str())
}
/// Removes the extension from the path
pub fn remove_extension(path: &Path) -> OsString {
let dirname = dirname(path);
let stem = path.file_stem().unwrap_or_else(|| path.as_os_str());
let stem = path.file_stem().unwrap_or(path.as_os_str());
let path = PathBuf::from(dirname).join(stem);

View File

@ -112,7 +112,7 @@ fn ensure_current_directory_exists(current_directory: &Path) -> Result<()> {
}
}
fn extract_search_pattern<'a>(matches: &'a clap::ArgMatches) -> Result<&'a str> {
fn extract_search_pattern(matches: &clap::ArgMatches) -> Result<&'_ str> {
let pattern = matches
.value_of_os("pattern")
.map(|p| {

View File

@ -104,10 +104,7 @@ pub fn scan(path_vec: &[PathBuf], pattern: Arc<Regex>, config: Arc<Config>) -> R
match result {
Some(ignore::Error::Partial(_)) => (),
Some(err) => {
print_error(format!(
"Malformed pattern in global ignore file. {}.",
err.to_string()
));
print_error(format!("Malformed pattern in global ignore file. {}.", err));
}
None => (),
}
@ -119,10 +116,7 @@ pub fn scan(path_vec: &[PathBuf], pattern: Arc<Regex>, config: Arc<Config>) -> R
match result {
Some(ignore::Error::Partial(_)) => (),
Some(err) => {
print_error(format!(
"Malformed pattern in custom ignore file. {}.",
err.to_string()
));
print_error(format!("Malformed pattern in custom ignore file. {}.", err));
}
None => (),
}