@@ -28,14 +28,6 @@ pub struct FileDiff<'a> {
2828}
2929
3030impl < ' a > FileDiff < ' a > {
31- pub fn are_different ( & self ) -> bool {
32- self . are_different
33- }
34-
35- pub fn set_different ( & mut self , are_different : bool ) {
36- self . are_different = are_different;
37- }
38-
3931 fn new (
4032 file1 : & ' a mut FileData < ' a > ,
4133 file2 : & ' a mut FileData < ' a > ,
@@ -44,7 +36,7 @@ impl<'a> FileDiff<'a> {
4436 Self {
4537 file1,
4638 file2,
47- hunks : Hunks :: new ( ) ,
39+ hunks : Default :: default ( ) ,
4840 format_options,
4941 are_different : false ,
5042 }
@@ -105,10 +97,10 @@ impl<'a> FileDiff<'a> {
10597 . create_hunks_from_lcs ( & lcs_indices, num_lines1, num_lines2) ;
10698
10799 if diff. hunks . hunk_count ( ) > 0 {
108- diff. set_different ( true ) ;
100+ diff. are_different = true ;
109101 }
110102
111- if diff. are_different ( ) {
103+ if diff. are_different {
112104 if let Some ( show_if_different) = show_if_different {
113105 println ! ( "{}" , show_if_different) ;
114106 }
@@ -216,7 +208,7 @@ impl<'a> FileDiff<'a> {
216208 }
217209 }
218210
219- if self . are_different ( ) {
211+ if self . are_different {
220212 Ok ( DiffExitStatus :: Different )
221213 } else {
222214 Ok ( DiffExitStatus :: NotDifferent )
@@ -331,7 +323,7 @@ impl<'a> FileDiff<'a> {
331323 Self :: get_header( self . file2, self . format_options. label2( ) )
332324 ) ;
333325
334- let mut diff_disp = ContextDiffDisplay :: new ( ) ;
326+ let mut diff_disp = ContextDiffDisplay :: default ( ) ;
335327
336328 for hunk in self . hunks . hunks ( ) {
337329 // move cursor to the start of context for first hunk
@@ -458,7 +450,7 @@ impl<'a> FileDiff<'a> {
458450 Self :: get_header( self . file2, self . format_options. label2( ) )
459451 ) ;
460452
461- let mut diff_disp = UnifiedDiffDisplay :: new ( ) ;
453+ let mut diff_disp = UnifiedDiffDisplay :: default ( ) ;
462454
463455 for hunk in self . hunks . hunks ( ) {
464456 // move cursor to the start of context for first hunk
@@ -526,6 +518,7 @@ impl<'a> FileDiff<'a> {
526518 }
527519}
528520
521+ #[ derive( Default ) ]
529522pub struct UnifiedDiffDisplay {
530523 curr_pos1 : usize ,
531524 curr_pos2 : usize ,
@@ -540,18 +533,6 @@ pub struct UnifiedDiffDisplay {
540533}
541534
542535impl UnifiedDiffDisplay {
543- pub fn new ( ) -> Self {
544- Self {
545- curr_pos1 : 0 ,
546- curr_pos2 : 0 ,
547- context_start1 : 0 ,
548- context_start2 : 0 ,
549- hunk1_len : 0 ,
550- hunk2_len : 0 ,
551- hunk_lines : String :: new ( ) ,
552- }
553- }
554-
555536 pub fn write_line (
556537 & mut self ,
557538 file : & FileData ,
@@ -607,6 +588,7 @@ impl UnifiedDiffDisplay {
607588 }
608589}
609590
591+ #[ derive( Default ) ]
610592pub struct ContextDiffDisplay {
611593 curr_pos1 : usize ,
612594 curr_pos2 : usize ,
@@ -621,18 +603,6 @@ pub struct ContextDiffDisplay {
621603}
622604
623605impl ContextDiffDisplay {
624- pub fn new ( ) -> Self {
625- Self {
626- curr_pos1 : 0 ,
627- curr_pos2 : 0 ,
628- context_start1 : 0 ,
629- context_start2 : 0 ,
630- hunk1_len : 0 ,
631- hunk2_len : 0 ,
632- hunk_lines : [ String :: new ( ) , String :: new ( ) ] ,
633- }
634- }
635-
636606 pub fn set_context_start ( & mut self ) {
637607 self . context_start1 = self . curr_pos1 + 1 ;
638608 self . context_start2 = self . curr_pos2 + 1 ;
0 commit comments