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
# 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

View file

@ -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;
}

View file

@ -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)
}
}

View file

@ -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 {

View file

@ -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 {

View file

@ -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)