@@ -52,7 +52,7 @@ impl<'a> FileDiff<'a> {
5252 show_if_different : Option < String > ,
5353 ) -> io:: Result < DiffExitStatus > {
5454 if is_binary ( & path1) ? || is_binary ( & path2) ? {
55- return Self :: binary_file_diff ( & path1, & path2) ;
55+ Self :: binary_file_diff ( & path1, & path2)
5656 } else {
5757 let content1 = read_to_string ( & path1) ?. into_bytes ( ) ;
5858 let linereader1 = LineReader :: new ( & content1) ;
@@ -79,8 +79,8 @@ impl<'a> FileDiff<'a> {
7979 let num_lines1 = diff. file1 . lines ( ) . len ( ) ;
8080 let num_lines2 = diff. file2 . lines ( ) . len ( ) ;
8181 FileDiff :: histogram_lcs (
82- & diff. file1 ,
83- & diff. file2 ,
82+ diff. file1 ,
83+ diff. file2 ,
8484 0 ,
8585 num_lines1,
8686 0 ,
@@ -97,7 +97,7 @@ impl<'a> FileDiff<'a> {
9797 }
9898 }
9999
100- return diff. print ( ) ;
100+ diff. print ( )
101101 }
102102 }
103103
@@ -110,24 +110,24 @@ impl<'a> FileDiff<'a> {
110110
111111 if path1_file_type. is_file ( ) {
112112 let path1_file = path1. clone ( ) ;
113- let path1_file = path1_file. file_name ( ) . expect ( & COULD_NOT_UNWRAP_FILENAME ) ;
113+ let path1_file = path1_file. file_name ( ) . expect ( COULD_NOT_UNWRAP_FILENAME ) ;
114114 let path2 = path2. join ( path1_file) ;
115115
116116 if !check_existance ( & path2) ? {
117117 return Ok ( DiffExitStatus :: Trouble ) ;
118118 }
119119
120- return FileDiff :: file_diff ( path1, path2, format_options, None ) ;
120+ FileDiff :: file_diff ( path1, path2, format_options, None )
121121 } else {
122122 let path2_file = path2. clone ( ) ;
123- let path2_file = path2_file. file_name ( ) . expect ( & COULD_NOT_UNWRAP_FILENAME ) ;
123+ let path2_file = path2_file. file_name ( ) . expect ( COULD_NOT_UNWRAP_FILENAME ) ;
124124 let path1 = path1. join ( path2_file) ;
125125
126126 if !check_existance ( & path1) ? {
127127 return Ok ( DiffExitStatus :: Trouble ) ;
128128 }
129129
130- return FileDiff :: file_diff ( path1, path2, format_options, None ) ;
130+ FileDiff :: file_diff ( path1, path2, format_options, None )
131131 }
132132 }
133133
@@ -173,22 +173,22 @@ impl<'a> FileDiff<'a> {
173173 for hunk_index in 0 ..hunks_count {
174174 let hunk = self . hunks . hunk_at_mut ( hunk_index) ;
175175 match self . format_options . output_format {
176- OutputFormat :: Debug => hunk. print_debug ( & self . file1 , & self . file2 ) ,
176+ OutputFormat :: Debug => hunk. print_debug ( self . file1 , self . file2 ) ,
177177 OutputFormat :: Default => {
178- hunk. print_default ( & self . file1 , & self . file2 , hunk_index == hunks_count - 1 )
178+ hunk. print_default ( self . file1 , self . file2 , hunk_index == hunks_count - 1 )
179179 }
180180 OutputFormat :: EditScript => hunk. print_edit_script (
181- & self . file1 ,
182- & self . file2 ,
181+ self . file1 ,
182+ self . file2 ,
183183 hunk_index == hunks_count - 1 ,
184184 ) ,
185185 OutputFormat :: Context ( _) => {
186186 eprintln ! ( "OutputFormat::Context should be handled in other place" ) ;
187187 return Ok ( DiffExitStatus :: Trouble ) ;
188188 }
189189 OutputFormat :: ForwardEditScript => hunk. print_forward_edit_script (
190- & self . file1 ,
191- & self . file2 ,
190+ self . file1 ,
191+ self . file2 ,
192192 hunk_index == hunks_count - 1 ,
193193 ) ,
194194 OutputFormat :: Unified ( _) => {
@@ -200,9 +200,9 @@ impl<'a> FileDiff<'a> {
200200 }
201201
202202 if self . are_different ( ) {
203- return Ok ( DiffExitStatus :: Different ) ;
203+ Ok ( DiffExitStatus :: Different )
204204 } else {
205- return Ok ( DiffExitStatus :: NotDifferent ) ;
205+ Ok ( DiffExitStatus :: NotDifferent )
206206 }
207207 }
208208
@@ -269,9 +269,7 @@ impl<'a> FileDiff<'a> {
269269 . map ( |( k, _v) | * k) ;
270270
271271 match key {
272- None => {
273- return ;
274- }
272+ None => { } ,
275273 Some ( k) => {
276274 let rec = hist. get ( k) . unwrap ( ) ;
277275 let x1_new = rec[ 1 ] as usize ;
@@ -308,11 +306,11 @@ impl<'a> FileDiff<'a> {
308306 fn print_context ( & mut self , context : usize ) {
309307 println ! (
310308 "*** {}" ,
311- Self :: get_header( self . file1, & self . format_options. label1( ) )
309+ Self :: get_header( self . file1, self . format_options. label1( ) )
312310 ) ;
313311 println ! (
314312 "--- {}" ,
315- Self :: get_header( self . file2, & self . format_options. label2( ) )
313+ Self :: get_header( self . file2, self . format_options. label2( ) )
316314 ) ;
317315
318316 for hunk in self . hunks . hunks ( ) {
@@ -384,11 +382,11 @@ impl<'a> FileDiff<'a> {
384382 fn print_unified ( & mut self , unified : usize ) -> Result < ( ) , std:: fmt:: Error > {
385383 println ! (
386384 "--- {}" ,
387- Self :: get_header( self . file1, & self . format_options. label1( ) )
385+ Self :: get_header( self . file1, self . format_options. label1( ) )
388386 ) ;
389387 println ! (
390388 "+++ {}" ,
391- Self :: get_header( self . file2, & self . format_options. label2( ) )
389+ Self :: get_header( self . file2, self . format_options. label2( ) )
392390 ) ;
393391
394392 let mut diff_disp = DiffDisplay :: new ( ) ;
@@ -448,13 +446,13 @@ impl<'a> FileDiff<'a> {
448446
449447 pub fn get_header ( file : & FileData , label : & Option < String > ) -> String {
450448 if let Some ( label) = label {
451- return format ! ( "{}" , label) ;
449+ label. to_string ( )
452450 } else {
453- return format ! (
451+ format ! (
454452 "{}\t {}" ,
455453 file. path( ) ,
456454 system_time_to_rfc2822( file. modified( ) )
457- ) ;
455+ )
458456 }
459457 }
460458}
0 commit comments