@@ -28,14 +28,6 @@ pub struct FileDiff<'a> {
28
28
}
29
29
30
30
impl < ' 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
-
39
31
fn new (
40
32
file1 : & ' a mut FileData < ' a > ,
41
33
file2 : & ' a mut FileData < ' a > ,
@@ -44,7 +36,7 @@ impl<'a> FileDiff<'a> {
44
36
Self {
45
37
file1,
46
38
file2,
47
- hunks : Hunks :: new ( ) ,
39
+ hunks : Default :: default ( ) ,
48
40
format_options,
49
41
are_different : false ,
50
42
}
@@ -105,10 +97,10 @@ impl<'a> FileDiff<'a> {
105
97
. create_hunks_from_lcs ( & lcs_indices, num_lines1, num_lines2) ;
106
98
107
99
if diff. hunks . hunk_count ( ) > 0 {
108
- diff. set_different ( true ) ;
100
+ diff. are_different = true ;
109
101
}
110
102
111
- if diff. are_different ( ) {
103
+ if diff. are_different {
112
104
if let Some ( show_if_different) = show_if_different {
113
105
println ! ( "{}" , show_if_different) ;
114
106
}
@@ -216,7 +208,7 @@ impl<'a> FileDiff<'a> {
216
208
}
217
209
}
218
210
219
- if self . are_different ( ) {
211
+ if self . are_different {
220
212
Ok ( DiffExitStatus :: Different )
221
213
} else {
222
214
Ok ( DiffExitStatus :: NotDifferent )
@@ -331,7 +323,7 @@ impl<'a> FileDiff<'a> {
331
323
Self :: get_header( self . file2, self . format_options. label2( ) )
332
324
) ;
333
325
334
- let mut diff_disp = ContextDiffDisplay :: new ( ) ;
326
+ let mut diff_disp = ContextDiffDisplay :: default ( ) ;
335
327
336
328
for hunk in self . hunks . hunks ( ) {
337
329
// move cursor to the start of context for first hunk
@@ -458,7 +450,7 @@ impl<'a> FileDiff<'a> {
458
450
Self :: get_header( self . file2, self . format_options. label2( ) )
459
451
) ;
460
452
461
- let mut diff_disp = UnifiedDiffDisplay :: new ( ) ;
453
+ let mut diff_disp = UnifiedDiffDisplay :: default ( ) ;
462
454
463
455
for hunk in self . hunks . hunks ( ) {
464
456
// move cursor to the start of context for first hunk
@@ -526,6 +518,7 @@ impl<'a> FileDiff<'a> {
526
518
}
527
519
}
528
520
521
+ #[ derive( Default ) ]
529
522
pub struct UnifiedDiffDisplay {
530
523
curr_pos1 : usize ,
531
524
curr_pos2 : usize ,
@@ -540,18 +533,6 @@ pub struct UnifiedDiffDisplay {
540
533
}
541
534
542
535
impl 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
-
555
536
pub fn write_line (
556
537
& mut self ,
557
538
file : & FileData ,
@@ -607,6 +588,7 @@ impl UnifiedDiffDisplay {
607
588
}
608
589
}
609
590
591
+ #[ derive( Default ) ]
610
592
pub struct ContextDiffDisplay {
611
593
curr_pos1 : usize ,
612
594
curr_pos2 : usize ,
@@ -621,18 +603,6 @@ pub struct ContextDiffDisplay {
621
603
}
622
604
623
605
impl 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
-
636
606
pub fn set_context_start ( & mut self ) {
637
607
self . context_start1 = self . curr_pos1 + 1 ;
638
608
self . context_start2 = self . curr_pos2 + 1 ;
0 commit comments