1
1
#![ allow( dead_code) ]
2
+ #![ allow( clippy:: unit_arg) ]
2
3
3
4
mod input;
4
5
mod text_effects;
5
6
mod utils;
6
7
use std:: os:: unix:: fs:: { FileTypeExt , MetadataExt } ;
8
+ use std:: path:: Path ;
7
9
use structopt:: StructOpt ;
8
10
use std:: cmp:: Ordering ;
9
11
@@ -44,7 +46,7 @@ enum PathType {
44
46
}
45
47
46
48
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 > > {
48
50
let mut return_val = Vec :: new ( ) ;
49
51
if file. symlink_metadata ( ) ?. is_dir ( ) { return_val. push ( Self :: Dir ) }
50
52
if file. symlink_metadata ( ) ?. file_type ( ) . is_symlink ( ) { return_val. push ( Self :: Symlink ) }
@@ -91,7 +93,7 @@ impl PathType {
91
93
}
92
94
}
93
95
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 {
95
97
match self {
96
98
Self :: Dir => text_effects:: bold ( & format ! ( "{}{}/" , name, termion:: color:: Fg ( termion:: color:: White ) ) ) ,
97
99
Self :: Symlink => text_effects:: italic ( & format ! ( "{} -> {}" , name, std:: fs:: read_link( file) . unwrap( ) . display( ) . to_string( ) ) ) ,
@@ -229,7 +231,7 @@ impl Directory {
229
231
. to_lowercase ( )
230
232
)
231
233
} ) ,
232
- DirSortType :: Created => sort_as ( & mut self . paths , |a, b| {
234
+ DirSortType :: Created => sort_as ( & mut self . paths , |a, b| {
233
235
a. path
234
236
. symlink_metadata ( )
235
237
. unwrap ( )
@@ -242,7 +244,7 @@ impl Directory {
242
244
. unwrap ( )
243
245
)
244
246
} ) ,
245
- DirSortType :: Modified => sort_as ( & mut self . paths , |a, b| {
247
+ DirSortType :: Modified => sort_as ( & mut self . paths , |a, b| {
246
248
a. path
247
249
. symlink_metadata ( )
248
250
. unwrap ( )
@@ -255,7 +257,7 @@ impl Directory {
255
257
. unwrap ( )
256
258
)
257
259
} ) ,
258
- DirSortType :: Size => sort_as ( & mut self . paths , |a, b| {
260
+ DirSortType :: Size => sort_as ( & mut self . paths , |a, b| {
259
261
a. path
260
262
. symlink_metadata ( )
261
263
. unwrap ( )
@@ -270,7 +272,6 @@ impl Directory {
270
272
}
271
273
}
272
274
273
-
274
275
fn sort ( & mut self ) {
275
276
match self . args . gdf {
276
277
true => self . sort_directory_then_path ( ) ,
@@ -419,14 +420,13 @@ impl std::fmt::Debug for File {
419
420
& self . path
420
421
) ;
421
422
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 ;
425
424
}
425
+ res = v. get_text_traits_for_type ( & res, & self . path ) ;
426
+ res = format ! ( "{}{}" , v. get_color_for_type( ) , res) ;
426
427
}
427
428
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 } ;
430
430
431
431
writeln ! ( f, "{} {green}{} {yellow}{} {blue} {}{} {}" ,
432
432
self . perms, self . size, self . user, self . group, time, res,
0 commit comments