Skip to content

Commit 188b6b0

Browse files
committed
Updated dependencies and used cargo clippy suggestions
1 parent 7d66a45 commit 188b6b0

File tree

5 files changed

+44
-36
lines changed

5 files changed

+44
-36
lines changed

Cargo.lock

+24-15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+5-5
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ edition = "2018"
99

1010
[dependencies]
1111
chrono = "0.4.19"
12-
filetime = "0.2.13"
13-
humansize = "1.1.0"
14-
libc = "0.2.80"
12+
filetime = "0.2.14"
13+
humansize = "1.1.1"
14+
libc = "0.2.95"
1515
pretty-bytes = "0.2.2"
16-
structopt = "0.3.20"
17-
termion = "1.5.5"
16+
structopt = "0.3.21"
17+
termion = "1.5.6"
1818
users = "0.11.0"
1919

2020

src/main.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#![allow(dead_code)]
2+
#![allow(clippy::unit_arg)]
23

34
mod input;
45
mod text_effects;
56
mod utils;
67
use std::os::unix::fs::{FileTypeExt, MetadataExt};
8+
use std::path::Path;
79
use structopt::StructOpt;
810
use std::cmp::Ordering;
911

@@ -44,7 +46,7 @@ enum PathType {
4446
}
4547

4648
impl PathType {
47-
fn new(file: &std::path::PathBuf) -> Result<Vec<Self>, Box<dyn std::error::Error>> {
49+
fn new(file: &Path) -> Result<Vec<Self>, Box<dyn std::error::Error>> {
4850
let mut return_val = Vec::new();
4951
if file.symlink_metadata()?.is_dir() {return_val.push(Self::Dir) }
5052
if file.symlink_metadata()?.file_type().is_symlink() {return_val.push(Self::Symlink)}
@@ -91,7 +93,7 @@ impl PathType {
9193
}
9294
}
9395

94-
fn get_text_traits_for_type(&self, name: &str, file: &std::path::PathBuf) -> String {
96+
fn get_text_traits_for_type(&self, name: &str, file: &Path) -> String {
9597
match self {
9698
Self::Dir => text_effects::bold(&format!( "{}{}/", name, termion::color::Fg(termion::color::White))),
9799
Self::Symlink => text_effects::italic(&format!( "{} -> {}", name, std::fs::read_link(file).unwrap().display().to_string())),
@@ -229,7 +231,7 @@ impl Directory {
229231
.to_lowercase()
230232
)
231233
}),
232-
DirSortType::Created => sort_as(&mut self.paths ,|a, b| {
234+
DirSortType::Created => sort_as(&mut self.paths, |a, b| {
233235
a.path
234236
.symlink_metadata()
235237
.unwrap()
@@ -242,7 +244,7 @@ impl Directory {
242244
.unwrap()
243245
)
244246
}),
245-
DirSortType::Modified => sort_as(&mut self.paths, |a, b| {
247+
DirSortType::Modified => sort_as(&mut self.paths, |a, b| {
246248
a.path
247249
.symlink_metadata()
248250
.unwrap()
@@ -255,7 +257,7 @@ impl Directory {
255257
.unwrap()
256258
)
257259
}),
258-
DirSortType::Size => sort_as(&mut self.paths, |a, b| {
260+
DirSortType::Size => sort_as(&mut self.paths, |a, b| {
259261
a.path
260262
.symlink_metadata()
261263
.unwrap()
@@ -270,7 +272,6 @@ impl Directory {
270272
}
271273
}
272274

273-
274275
fn sort(&mut self) {
275276
match self.args.gdf {
276277
true => self.sort_directory_then_path(),
@@ -419,14 +420,13 @@ impl std::fmt::Debug for File {
419420
&self.path
420421
);
421422
res = format!("{}{}", v.get_color_for_type(), res);
422-
} else {
423-
res = v.get_text_traits_for_type(&res, &self.path);
424-
res = format!("{}{}", v.get_color_for_type(), res);
423+
continue;
425424
}
425+
res = v.get_text_traits_for_type(&res, &self.path);
426+
res = format!("{}{}", v.get_color_for_type(), res);
426427
}
427428

428-
let time = if input::Cli::from_args().created_time { &self.created }
429-
else { &self.modified };
429+
let time = if input::Cli::from_args().created_time { &self.created } else { &self.modified };
430430

431431
writeln!(f, "{} {green}{} {yellow}{} {blue} {}{} {}",
432432
self.perms, self.size, self.user, self.group, time, res,

src/utils/group_user.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ use std::os::unix::fs::MetadataExt;
22

33
pub fn group(path: std::path::PathBuf) -> String {
44
let group = users::get_group_by_gid(path.symlink_metadata().unwrap().gid());
5-
if group.is_some() {
6-
String::from(group.unwrap().name().to_string_lossy())
5+
if let Some(g) = group {
6+
String::from(g.name().to_string_lossy())
77
} else {
88
String::from(" ")
99
}
1010
}
1111

1212
pub fn user(path: std::path::PathBuf) -> String {
1313
let user = users::get_user_by_uid(path.symlink_metadata().unwrap().uid());
14-
if user.is_some(){
15-
String::from(user.unwrap().name().to_string_lossy())
14+
if let Some(u) = user {
15+
String::from(u.name().to_string_lossy())
1616
} else {
1717
String::from(" ")
1818
}

src/utils/perms.rs

-1
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,4 @@ fn masking(mode: u16, read: u16, write: u16, execute: u16) -> String {
6969
termion::color::Fg(termion::color::Reset)
7070
),
7171
}
72-
.to_string()
7372
}

0 commit comments

Comments
 (0)