@@ -31,28 +31,24 @@ pub struct FileDiff<'a> {
3131}
3232
3333impl < ' a > FileDiff < ' a > {
34- pub fn are_different ( & self ) -> bool {
35- self . are_different
36- }
37-
3834 fn new (
3935 file1 : & ' a mut FileData ,
4036 file2 : & ' a mut FileData ,
4137 format_options : & ' a FormatOptions ,
4238 ) -> Self {
43- if format_options. label1 . is_none ( ) && format_options. label2 . is_some ( ) {
44- panic ! ( "label1 can not be NONE when label2 is available" ) ;
45- }
46-
4739 Self {
4840 file1,
4941 file2,
5042 hunks : Hunks :: new ( ) ,
51- format_options : format_options ,
43+ format_options,
5244 are_different : false ,
5345 }
5446 }
5547
48+ pub fn are_different ( & self ) -> bool {
49+ self . are_different
50+ }
51+
5652 pub fn file_diff (
5753 path1 : PathBuf ,
5854 path2 : PathBuf ,
@@ -362,11 +358,11 @@ impl<'a> FileDiff<'a> {
362358 fn print_context ( & mut self , context : usize ) {
363359 println ! (
364360 "*** {}" ,
365- Self :: get_header( self . file1, & self . format_options. label1)
361+ Self :: get_header( self . file1, & self . format_options. label1( ) )
366362 ) ;
367363 println ! (
368364 "--- {}" ,
369- Self :: get_header( self . file2, & self . format_options. label2)
365+ Self :: get_header( self . file2, & self . format_options. label2( ) )
370366 ) ;
371367
372368 let change_ranges = self . get_context_ranges ( context) ;
@@ -423,11 +419,11 @@ impl<'a> FileDiff<'a> {
423419 fn print_unified ( & mut self , unified : usize ) {
424420 println ! (
425421 "--- {}" ,
426- Self :: get_header( self . file1, & self . format_options. label1)
422+ Self :: get_header( self . file1, & self . format_options. label1( ) )
427423 ) ;
428424 println ! (
429425 "+++ {}" ,
430- Self :: get_header( self . file2, & self . format_options. label2)
426+ Self :: get_header( self . file2, & self . format_options. label2( ) )
431427 ) ;
432428
433429 let context_ranges = self . get_context_ranges ( unified) ;
0 commit comments