Some Clippy fixes

This commit is contained in:
Benjamin Sago 2020-10-10 13:33:50 +01:00
parent 39c3f15602
commit 74d9f1402b
6 changed files with 15 additions and 12 deletions

View File

@ -11,7 +11,7 @@ all-release: build-release test-release
cargo build --release --verbose cargo build --release --verbose
# compiles the exa binary with every combination of feature flags # compiles the exa binary with every combination of feature flags
build-features: @build-features:
cargo hack build --feature-powerset cargo hack build --feature-powerset
@ -24,16 +24,20 @@ build-features:
cargo test --release --all --verbose cargo test --release --all --verbose
# runs unit tests with every combination of feature flags # runs unit tests with every combination of feature flags
test-features: @test-features:
cargo hack test --feature-powerset -- --quiet cargo hack test --feature-powerset -- --quiet
# lints the code
@clippy:
touch src/main.rs
cargo clippy
# updates dependency versions, and checks for outdated ones # updates dependency versions, and checks for outdated ones
@update: @update:
cargo update cargo update
cargo outdated cargo outdated
# prints versions of the necessary build tools # prints versions of the necessary build tools
@versions: @versions:
rustc --version rustc --version

View File

@ -104,7 +104,7 @@ pub fn list_attrs(lister: &lister::Lister, path: &Path) -> io::Result<Vec<Attrib
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
mod lister { mod lister {
use std::ffi::CString; 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 super::FollowSymlinks;
use std::ptr; use std::ptr;
@ -116,7 +116,7 @@ mod lister {
fn getxattr( fn getxattr(
path: *const c_char, name: *const c_char, 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 options: c_int
) -> ssize_t; ) -> ssize_t;
} }

View File

@ -50,10 +50,7 @@ pub enum Type {
impl Type { impl Type {
pub fn is_regular_file(&self) -> bool { pub fn is_regular_file(&self) -> bool {
match *self { matches!(*self, Type::File)
Type::File => true,
_ => false,
}
} }
} }

View File

@ -338,7 +338,7 @@ impl<'dir> File<'dir> {
if sec < 0 { if sec < 0 {
if nsec > 0 { if nsec > 0 {
sec += 1; 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) UNIX_EPOCH - Duration::new(sec.abs() as u64, nsec.abs() as u32)
} else { } else {

View File

@ -5,7 +5,7 @@ use crate::fs::fields as f;
impl f::OctalPermissions { impl f::OctalPermissions {
fn bits_to_octal(r: bool, w: bool, x: bool) -> u8 { 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 { pub fn render(&self, style: Style) -> TextCell {

View File

@ -25,7 +25,9 @@ use ansi_term::Colour::*;
pub struct LSColors<'var>(pub &'var str); pub struct LSColors<'var>(pub &'var str);
impl<'var> LSColors<'var> { 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(':') { for next in self.0.split(':') {
let bits = next.split('=') let bits = next.split('=')
.take(3) .take(3)