@@ -24,7 +24,7 @@ pub mod searcher {
2424
2525 pub type ResultAsync < T > = std:: result:: Result < T , Box < dyn std:: error:: Error + Send + Sync > > ;
2626
27- #[ derive( Debug , PartialEq , Eq , Ord ) ]
27+ #[ derive( Debug , PartialEq , Eq ) ]
2828 pub struct FileData {
2929 pub path : String ,
3030 pub file_name : String ,
@@ -59,21 +59,27 @@ pub mod searcher {
5959 Self {
6060 path : self . path . clone ( ) ,
6161 file_name : self . file_name . clone ( ) ,
62- size : self . size . clone ( ) ,
63- last_modified : self . last_modified . clone ( ) ,
64- is_readonly : self . is_readonly . clone ( ) ,
62+ size : self . size ,
63+ last_modified : self . last_modified ,
64+ is_readonly : self . is_readonly ,
6565 sha : self . sha . clone ( ) ,
6666 }
6767 }
6868 }
6969
7070 impl PartialOrd for FileData {
7171 fn partial_cmp ( & self , other : & Self ) -> Option < std:: cmp:: Ordering > {
72+ Some ( self . cmp ( other) )
73+ }
74+ }
75+
76+ impl Ord for FileData {
77+ fn cmp ( & self , other : & Self ) -> std:: cmp:: Ordering {
7278 if self . file_name . eq ( & other. file_name ) {
73- return Some ( self . size . cmp ( & other. size ) ) ;
79+ return self . size . cmp ( & other. size ) ;
7480 }
7581
76- Some ( self . file_name . cmp ( & other. file_name ) )
82+ self . file_name . cmp ( & other. file_name )
7783 }
7884 }
7985
@@ -91,7 +97,7 @@ pub mod searcher {
9197
9298 pub async fn search_duplicates ( cmds : & CmdArgs ) {
9399 let msg = format ! ( "Looking in to path {:?}" , cmds. root_folder) ;
94- let mut sp = Spinner :: new ( Spinners :: Aesthetic , msg. into ( ) ) ;
100+ let mut sp = Spinner :: new ( Spinners :: Aesthetic , msg) ;
95101
96102 let path = PathBuf :: from ( cmds. root_folder . clone ( ) ) ;
97103 let file_data: Vec < FileData > = vec ! [ ] ;
@@ -165,8 +171,7 @@ pub mod searcher {
165171
166172 if !duplicates. is_empty ( ) {
167173 println ! (
168- "{} {} size {}" ,
169- "File " ,
174+ "File {} size {}" ,
170175 a_file_date. file_name. bold( ) . green( ) ,
171176 a_file_date. size. to_string( ) . cyan( )
172177 ) ;
@@ -194,7 +199,7 @@ pub mod searcher {
194199 if is_score_ok {
195200 return a_file_date. sha . eq_ignore_ascii_case ( & file. sha ) ;
196201 }
197- return false ;
202+ false
198203 }
199204 }
200205 }
@@ -310,7 +315,7 @@ pub mod searcher {
310315 size,
311316 last_modified,
312317 is_readonly,
313- sha : sha ,
318+ sha,
314319 } ;
315320 the_file_data
316321 }
@@ -319,7 +324,7 @@ pub mod searcher {
319324 match fs:: metadata ( path) . await {
320325 Err ( err) => {
321326 eprintln ! ( "Error reading metadata {:?} error {:?}" , path, err) ;
322- return Option :: None ;
327+ Option :: None
323328 }
324329 Ok ( metadata) => Option :: Some ( metadata) ,
325330 }
0 commit comments