@@ -19,7 +19,11 @@ use std::fs;
19
19
use std:: io:: { self , BufRead , BufReader , Read } ;
20
20
use std:: iter:: Peekable ;
21
21
use std:: path:: { Path , PathBuf } ;
22
+ <<<<<<< HEAD
22
23
use std:: str:: Chars ;
24
+ =======
25
+ use std:: str:: Bytes ;
26
+ >>>>>>> c41b45169a6a8b461d6615fb59ade61182daf5f5
23
27
24
28
use rustfmt:: * ;
25
29
use rustfmt:: filemap:: { write_system_newlines , FileMap } ;
@@ -436,6 +440,7 @@ fn rustfmt_diff_no_diff_test() {
436
440
437
441
// Compare strings without distinguishing between CRLF and LF
438
442
fn string_eq_ignore_newline_repr ( left : & str , right : & str ) -> bool {
443
+ <<<<<<< HEAD
439
444
let left = CharsIgnoreNewlineRepr ( left. chars( ) . peekable( ) ) ;
440
445
let right = CharsIgnoreNewlineRepr ( right. chars( ) . peekable( ) ) ;
441
446
left. eq( right)
@@ -452,6 +457,24 @@ impl<'a> Iterator for CharsIgnoreNewlineRepr<'a> {
452
457
'\n'
453
458
} else {
454
459
'\r'
460
+ =======
461
+ let left = BytesIgnoreNewlineRepr ( left. bytes( ) . peekable( ) ) ;
462
+ let right = BytesIgnoreNewlineRepr ( right. bytes( ) . peekable( ) ) ;
463
+ left. eq( right)
464
+ }
465
+
466
+ struct BytesIgnoreNewlineRepr < ' a > ( Peekable < Bytes < ' a > > ) ;
467
+
468
+ impl <' a > Iterator for BytesIgnoreNewlineRepr < ' a > {
469
+ type Item = u8 ;
470
+ fn next ( & mut self ) -> Option < u8 > {
471
+ self . 0 . next( ) . map( |c| if c == b'\r' {
472
+ if * self . 0 . peek( ) . unwrap_or( & 0 ) == b'\n' {
473
+ self . 0 . next( ) ;
474
+ b'\n'
475
+ } else {
476
+ b'\r'
477
+ >>>>>>> c41b45169a6a8b461d6615fb59ade61182daf5f5
455
478
}
456
479
} else {
457
480
c
@@ -461,10 +484,14 @@ impl<'a> Iterator for CharsIgnoreNewlineRepr<'a> {
461
484
462
485
#[ test]
463
486
fn string_eq_ignore_newline_repr_test( ) {
487
+ <<<<<<< HEAD
464
488
assert ! ( string_eq_ignore_newline_repr( "" , "" ) ) ;
465
489
assert ! ( !string_eq_ignore_newline_repr( "" , "abc" ) ) ;
466
490
assert ! ( !string_eq_ignore_newline_repr( "abc" , "" ) ) ;
467
491
assert ! ( string_eq_ignore_newline_repr( "a\n b\n c\r d" , "a\n b\r \n c\r d" ) ) ;
468
492
assert ! ( string_eq_ignore_newline_repr( "a\r \n \r \n \r \n b" , "a\n \n \n b" ) ) ;
469
493
assert ! ( !string_eq_ignore_newline_repr( "a\r \n bcd" , "a\n bcdefghijk" ) ) ;
494
+ =======
495
+ assert ! ( string_eq_ignore_newline_repr( "a\n b\n c\r d" , "a\n b\r \n c\r d" ) ) ;
496
+ >>>>>>> c41b45169a6a8b461d6615fb59ade61182daf5f5
470
497
}
0 commit comments