فهرست منبع

refactor(clippy): trivial clippy lints

Signed-off-by: Christina Sørensen <christina@cafkafk.com>
Christina Sørensen 2 سال پیش
والد
کامیت
cba4c50df6
9فایلهای تغییر یافته به همراه31 افزوده شده و 31 حذف شده
  1. 3 3
      src/fs/feature/git.rs
  2. 1 1
      src/fs/fields.rs
  3. 3 3
      src/fs/filter.rs
  4. 1 1
      src/logger.rs
  5. 13 13
      src/options/error.rs
  6. 6 6
      src/options/help.rs
  7. 2 2
      src/options/parser.rs
  8. 1 1
      src/options/view.rs
  9. 1 1
      src/output/grid.rs

+ 3 - 3
src/fs/feature/git.rs

@@ -314,8 +314,8 @@ fn reorient(path: &Path) -> PathBuf {
 
     // TODO: I’m not 100% on this func tbh
     let path = match current_dir() {
-        Err(_)   => Path::new(".").join(&path),
-        Ok(dir)  => dir.join(&path),
+        Err(_)   => Path::new(".").join(path),
+        Ok(dir)  => dir.join(path),
     };
 
     path.canonicalize().unwrap_or(path)
@@ -381,7 +381,7 @@ fn current_branch(repo: &git2::Repository) -> Option<String>{
 impl f::SubdirGitRepo{
     pub fn from_path(dir : &Path, status : bool) -> Self{
 
-        let path = &reorient(&dir);
+        let path = &reorient(dir);
         let g = git2::Repository::open(path);
         if let Ok(repo) = g{
 

+ 1 - 1
src/fs/fields.rs

@@ -82,7 +82,7 @@ pub struct Permissions {
     pub setuid:         bool,
 }
 
-/// The file's FileAttributes field, available only on Windows.
+/// The file's `FileAttributes` field, available only on Windows.
 #[derive(Copy, Clone)]
 pub struct Attributes {
     pub archive:         bool,

+ 3 - 3
src/fs/filter.rs

@@ -234,17 +234,17 @@ impl SortField {
             Self::ModifiedAge   => b.modified_time().cmp(&a.modified_time()),  // flip b and a
 
             Self::FileType => match a.type_char().cmp(&b.type_char()) { // todo: this recomputes
-                Ordering::Equal  => natord::compare(&*a.name, &*b.name),
+                Ordering::Equal  => natord::compare(&a.name, &b.name),
                 order            => order,
             },
 
             Self::Extension(ABCabc) => match a.ext.cmp(&b.ext) {
-                Ordering::Equal  => natord::compare(&*a.name, &*b.name),
+                Ordering::Equal  => natord::compare(&a.name, &b.name),
                 order            => order,
             },
 
             Self::Extension(AaBbCc) => match a.ext.cmp(&b.ext) {
-                Ordering::Equal  => natord::compare_ignore_case(&*a.name, &*b.name),
+                Ordering::Equal  => natord::compare_ignore_case(&a.name, &b.name),
                 order            => order,
             },
 

+ 1 - 1
src/logger.rs

@@ -27,7 +27,7 @@ pub fn configure<T: AsRef<OsStr>>(ev: Option<T>) {
 
     let result = log::set_logger(GLOBAL_LOGGER);
     if let Err(e) = result {
-        eprintln!("Failed to initialise logger: {}", e);
+        eprintln!("Failed to initialise logger: {e}");
     }
 }
 

+ 13 - 13
src/options/error.rs

@@ -63,8 +63,8 @@ impl From<glob::PatternError> for OptionsError {
 impl fmt::Display for NumberSource {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
         match self {
-            Self::Arg(arg) => write!(f, "option {}", arg),
-            Self::Env(env) => write!(f, "environment variable {}", env),
+            Self::Arg(arg) => write!(f, "option {arg}"),
+            Self::Env(env) => write!(f, "environment variable {env}"),
         }
     }
 }
@@ -79,20 +79,20 @@ impl fmt::Display for OptionsError {
                     write!(f, "Option {} has no {:?} setting ({})", arg, attempt, Choices(values))
                 }
                 else {
-                    write!(f, "Option {} has no {:?} setting", arg, attempt)
+                    write!(f, "Option {arg} has no {attempt:?} setting")
                 }
             }
-            Self::Parse(e)                   => write!(f, "{}", e),
-            Self::Unsupported(e)             => write!(f, "{}", e),
-            Self::Conflict(a, b)             => write!(f, "Option {} conflicts with option {}", a, b),
-            Self::Duplicate(a, b) if a == b  => write!(f, "Flag {} was given twice", a),
-            Self::Duplicate(a, b)            => write!(f, "Flag {} conflicts with flag {}", a, b),
-            Self::Useless(a, false, b)       => write!(f, "Option {} is useless without option {}", a, b),
-            Self::Useless(a, true, b)        => write!(f, "Option {} is useless given option {}", a, b),
-            Self::Useless2(a, b1, b2)        => write!(f, "Option {} is useless without options {} or {}", a, b1, b2),
+            Self::Parse(e)                   => write!(f, "{e}"),
+            Self::Unsupported(e)             => write!(f, "{e}"),
+            Self::Conflict(a, b)             => write!(f, "Option {a} conflicts with option {b}"),
+            Self::Duplicate(a, b) if a == b  => write!(f, "Flag {a} was given twice"),
+            Self::Duplicate(a, b)            => write!(f, "Flag {a} conflicts with flag {b}"),
+            Self::Useless(a, false, b)       => write!(f, "Option {a} is useless without option {b}"),
+            Self::Useless(a, true, b)        => write!(f, "Option {a} is useless given option {b}"),
+            Self::Useless2(a, b1, b2)        => write!(f, "Option {a} is useless without options {b1} or {b2}"),
             Self::TreeAllAll                 => write!(f, "Option --tree is useless given --all --all"),
-            Self::FailedParse(s, n, e)       => write!(f, "Value {:?} not valid for {}: {}", s, n, e),
-            Self::FailedGlobPattern(ref e)   => write!(f, "Failed to parse glob pattern: {}", e),
+            Self::FailedParse(s, n, e)       => write!(f, "Value {s:?} not valid for {n}: {e}"),
+            Self::FailedGlobPattern(ref e)   => write!(f, "Failed to parse glob pattern: {e}"),
         }
     }
 }

+ 6 - 6
src/options/help.rs

@@ -102,21 +102,21 @@ impl fmt::Display for HelpString {
     /// Format this help options into an actual string of help
     /// text to be displayed to the user.
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
-        write!(f, "{}", USAGE_PART1)?;
+        write!(f, "{USAGE_PART1}")?;
 
         if cfg!(feature = "git") {
-            write!(f, "\n{}", GIT_FILTER_HELP)?;
+            write!(f, "\n{GIT_FILTER_HELP}")?;
         }
 
-        write!(f, "\n{}", USAGE_PART2)?;
+        write!(f, "\n{USAGE_PART2}")?;
 
         if cfg!(feature = "git") {
-            write!(f, "\n{}", GIT_VIEW_HELP)?;
+            write!(f, "\n{GIT_VIEW_HELP}")?;
         }
 
         if xattr::ENABLED {
-            write!(f, "\n{}", EXTENDED_HELP)?;
-            write!(f, "\n{}", SECATTR_HELP)?;
+            write!(f, "\n{EXTENDED_HELP}")?;
+            write!(f, "\n{SECATTR_HELP}")?;
         }
 
         writeln!(f)

+ 2 - 2
src/options/parser.rs

@@ -71,7 +71,7 @@ impl fmt::Display for Flag {
     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
         match self {
             Self::Short(short)  => write!(f, "-{}", *short as char),
-            Self::Long(long)    => write!(f, "--{}", long),
+            Self::Long(long)    => write!(f, "--{long}"),
         }
     }
 }
@@ -330,7 +330,7 @@ impl Args {
         }
     }
 
-    fn lookup_long<'b>(&self, long: &'b OsStr) -> Result<&Arg, ParseError> {
+    fn lookup_long(&self, long: &OsStr) -> Result<&Arg, ParseError> {
         match self.0.iter().find(|arg| arg.long == long) {
             Some(arg)  => Ok(arg),
             None       => Err(ParseError::UnknownArgument { attempt: long.to_os_string() })

+ 1 - 1
src/options/view.rs

@@ -84,7 +84,7 @@ impl Mode {
             for option in &[ &flags::BINARY, &flags::BYTES, &flags::INODE, &flags::LINKS,
                              &flags::HEADER, &flags::BLOCKS, &flags::TIME, &flags::GROUP, &flags::NUMERIC ] {
                 if matches.has(option)? {
-                    return Err(OptionsError::Useless(*option, false, &flags::LONG));
+                    return Err(OptionsError::Useless(option, false, &flags::LONG));
                 }
             }
 

+ 1 - 1
src/output/grid.rs

@@ -54,7 +54,7 @@ impl<'a> Render<'a> {
                 contents:  contents.strings().to_string(),
                 // with hyperlink escape sequences,
                 // the actual *contents.width() is larger than actually needed, so we take only the filename
-                width:     width,
+                width,
             });
         }