diff options
author | Benjamin Sago <ogham@bsago.me> | 2020-10-10 13:33:50 +0100 |
---|---|---|
committer | Benjamin Sago <ogham@bsago.me> | 2020-10-10 13:33:50 +0100 |
commit | 74d9f1402b9f0a26a796d0197e44c24c78696693 (patch) | |
tree | 6fef47fcd03c54992218fcc359aa21433f10baf6 | |
parent | 39c3f15602e852fd1e37f77015643e99018bcbe2 (diff) |
Some Clippy fixes
-rw-r--r-- | Justfile | 10 | ||||
-rw-r--r-- | src/fs/feature/xattr.rs | 4 | ||||
-rw-r--r-- | src/fs/fields.rs | 5 | ||||
-rw-r--r-- | src/fs/file.rs | 2 | ||||
-rw-r--r-- | src/output/render/octal.rs | 2 | ||||
-rw-r--r-- | src/style/lsc.rs | 4 |
6 files changed, 15 insertions, 12 deletions
@@ -11,7 +11,7 @@ all-release: build-release test-release cargo build --release --verbose # compiles the exa binary with every combination of feature flags -build-features: +@build-features: cargo hack build --feature-powerset @@ -24,16 +24,20 @@ build-features: cargo test --release --all --verbose # runs unit tests with every combination of feature flags -test-features: +@test-features: cargo hack test --feature-powerset -- --quiet +# lints the code +@clippy: + touch src/main.rs + cargo clippy + # updates dependency versions, and checks for outdated ones @update: cargo update cargo outdated - # prints versions of the necessary build tools @versions: rustc --version diff --git a/src/fs/feature/xattr.rs b/src/fs/feature/xattr.rs index 333f3ff..f39e3c8 100644 --- a/src/fs/feature/xattr.rs +++ b/src/fs/feature/xattr.rs @@ -104,7 +104,7 @@ pub fn list_attrs(lister: &lister::Lister, path: &Path) -> io::Result<Vec<Attrib #[cfg(target_os = "macos")] mod lister { use std::ffi::CString; - use libc::{c_int, size_t, ssize_t, c_char, c_void, uint32_t}; + use libc::{c_int, size_t, ssize_t, c_char, c_void}; use super::FollowSymlinks; use std::ptr; @@ -116,7 +116,7 @@ mod lister { fn getxattr( path: *const c_char, name: *const c_char, - value: *mut c_void, size: size_t, position: uint32_t, + value: *mut c_void, size: size_t, position: u32, options: c_int ) -> ssize_t; } diff --git a/src/fs/fields.rs b/src/fs/fields.rs index 39a92b1..f3d6735 100644 --- a/src/fs/fields.rs +++ b/src/fs/fields.rs @@ -50,10 +50,7 @@ pub enum Type { impl Type { pub fn is_regular_file(&self) -> bool { - match *self { - Type::File => true, - _ => false, - } + matches!(*self, Type::File) } } diff --git a/src/fs/file.rs b/src/fs/file.rs index 60ac398..c22b815 100644 --- a/src/fs/file.rs +++ b/src/fs/file.rs @@ -338,7 +338,7 @@ impl<'dir> File<'dir> { if sec < 0 { if nsec > 0 { sec += 1; - nsec = nsec - 1_000_000_000; + nsec -= 1_000_000_000; } UNIX_EPOCH - Duration::new(sec.abs() as u64, nsec.abs() as u32) } else { diff --git a/src/output/render/octal.rs b/src/output/render/octal.rs index 7f8cf11..17e9585 100644 --- a/src/output/render/octal.rs +++ b/src/output/render/octal.rs @@ -5,7 +5,7 @@ use crate::fs::fields as f; impl f::OctalPermissions { fn bits_to_octal(r: bool, w: bool, x: bool) -> u8 { - (r as u8) * 4 + (w as u8) * 2 + (x as u8) * 1 + (r as u8) * 4 + (w as u8) * 2 + (x as u8) } pub fn render(&self, style: Style) -> TextCell { diff --git a/src/style/lsc.rs b/src/style/lsc.rs index fee9b07..571c034 100644 --- a/src/style/lsc.rs +++ b/src/style/lsc.rs @@ -25,7 +25,9 @@ use ansi_term::Colour::*; pub struct LSColors<'var>(pub &'var str); impl<'var> LSColors<'var> { - pub fn each_pair<C>(&mut self, mut callback: C) where C: FnMut(Pair<'var>) -> () { + pub fn each_pair<C>(&mut self, mut callback: C) + where C: FnMut(Pair<'var>) + { for next in self.0.split(':') { let bits = next.split('=') .take(3) |