diff --git a/src/meta/date.rs b/src/meta/date.rs index 2e43ef804..5675eacfc 100644 --- a/src/meta/date.rs +++ b/src/meta/date.rs @@ -84,7 +84,7 @@ mod test { Command::new("touch") .arg("-t") .arg(date.format("%Y%m%d%H%M.%S").to_string()) - .arg(&path) + .arg(path) .status() } diff --git a/src/meta/inode.rs b/src/meta/inode.rs index 7aac80594..c7d2dae47 100644 --- a/src/meta/inode.rs +++ b/src/meta/inode.rs @@ -41,7 +41,7 @@ mod tests { use std::process::{Command, ExitStatus}; fn cross_platform_touch(path: &Path) -> io::Result { - Command::new("touch").arg(&path).status() + Command::new("touch").arg(path).status() } #[test] diff --git a/src/meta/links.rs b/src/meta/links.rs index 237292874..6ee86129b 100644 --- a/src/meta/links.rs +++ b/src/meta/links.rs @@ -41,7 +41,7 @@ mod tests { use std::process::{Command, ExitStatus}; fn cross_platform_touch(path: &Path) -> io::Result { - Command::new("touch").arg(&path).status() + Command::new("touch").arg(path).status() } #[test] diff --git a/src/meta/locale.rs b/src/meta/locale.rs index 35edad6da..71bb6c01b 100644 --- a/src/meta/locale.rs +++ b/src/meta/locale.rs @@ -2,15 +2,14 @@ use chrono::Locale; use once_cell::sync::OnceCell; use sys_locale::get_locale; +fn locale_str() -> String { + get_locale().unwrap_or_default().replace('-', "_") +} + /// Finds current locale pub fn current_locale() -> Locale { const DEFAULT: Locale = Locale::en_US; static CACHE: OnceCell = OnceCell::new(); - fn locale_str() -> String { - get_locale().unwrap_or("".to_string()).replace('-', "_") - } - - *CACHE - .get_or_init(|| Locale::try_from(locale_str().as_str()).unwrap_or(DEFAULT)) + *CACHE.get_or_init(|| Locale::try_from(locale_str().as_str()).unwrap_or(DEFAULT)) } diff --git a/src/meta/mod.rs b/src/meta/mod.rs index c158858af..697cecb5c 100644 --- a/src/meta/mod.rs +++ b/src/meta/mod.rs @@ -330,7 +330,7 @@ mod tests { let path_c = tmp_dir.path().join("ccc.cc"); #[cfg(unix)] - std::os::unix::fs::symlink(&path_c, &path_b).expect("failed to create broken symlink"); + std::os::unix::fs::symlink(path_c, &path_b).expect("failed to create broken symlink"); // this needs to be tested on Windows // likely to fail because of permission issue diff --git a/src/meta/name.rs b/src/meta/name.rs index c8472d823..07cc4c7ae 100644 --- a/src/meta/name.rs +++ b/src/meta/name.rs @@ -117,7 +117,7 @@ impl Name { // HyperlinkOption::Auto gets converted to None or Always in core.rs based on tty_available match std::fs::canonicalize(&self.path) { Ok(rp) => { - if let Ok(url) = Url::from_file_path(&rp) { + if let Ok(url) = Url::from_file_path(rp) { // Crossterm does not support hyperlinks as of now // https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda format!("\x1B]8;;{}\x1B\x5C{}\x1B]8;;\x1B\x5C", url, name) @@ -426,7 +426,7 @@ mod test { let colors = Colors::new(color::ThemeOption::NoColor); let real_path = std::fs::canonicalize(&file_path).expect("canonicalize"); - let expected_url = Url::from_file_path(&real_path).expect("absolute path"); + let expected_url = Url::from_file_path(real_path).expect("absolute path"); let expected_text = format!( "\x1B]8;;{}\x1B\x5C{}\x1B]8;;\x1B\x5C", expected_url, "file.txt" diff --git a/src/meta/symlink.rs b/src/meta/symlink.rs index f7b296b5f..c46432eeb 100644 --- a/src/meta/symlink.rs +++ b/src/meta/symlink.rs @@ -12,7 +12,7 @@ pub struct SymLink { impl From<&Path> for SymLink { fn from(path: &Path) -> Self { if let Ok(target) = read_link(path) { - if target.is_absolute() || path.parent() == None { + if target.is_absolute() || path.parent().is_none() { return Self { valid: target.exists(), target: Some( diff --git a/src/sort.rs b/src/sort.rs index 6fb39cb60..87092830f 100644 --- a/src/sort.rs +++ b/src/sort.rs @@ -367,7 +367,7 @@ mod tests { let path_d = tmp_dir.path().join("ddd.dd"); #[cfg(unix)] - std::os::unix::fs::symlink(&path_d, &path_c).expect("failed to create broken symlink"); + std::os::unix::fs::symlink(path_d, &path_c).expect("failed to create broken symlink"); // this needs to be tested on Windows // likely to fail because of permission issue diff --git a/tests/integration.rs b/tests/integration.rs index c2d9cca5c..a43ce3565 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -297,7 +297,7 @@ fn test_dereference_link_broken_link_output() { let target = dir.path().join("target"); #[cfg(unix)] - fs::symlink(&target, &link).unwrap(); + fs::symlink(target, &link).unwrap(); // this needs to be tested on Windows // likely to fail because of permission issue @@ -369,7 +369,7 @@ fn test_show_folder_of_symlink_for_long_multi() { let dir = tempdir(); dir.child("target").child("inside").touch().unwrap(); let link = dir.path().join("link"); - fs::symlink("target", &link).unwrap(); + fs::symlink("target", link).unwrap(); cmd() .arg("-l") @@ -552,7 +552,7 @@ fn test_tree_no_dereference() { tmp.child("one.d").create_dir_all().unwrap(); tmp.child("one.d/samplefile").touch().unwrap(); let link = tmp.path().join("link"); - fs::symlink("one.d", &link).unwrap(); + fs::symlink("one.d", link).unwrap(); cmd() .arg("--tree") @@ -571,7 +571,7 @@ fn test_tree_dereference() { tmp.child("one.d").create_dir_all().unwrap(); tmp.child("one.d/samplefile").touch().unwrap(); let link = tmp.path().join("link"); - fs::symlink("one.d", &link).unwrap(); + fs::symlink("one.d", link).unwrap(); cmd() .arg("--ignore-config")