@@ -343,12 +343,12 @@ pub(crate) fn match_contains(
343
343
let expected = normalize_expected ( expected, redactions) ;
344
344
let actual = normalize_actual ( actual, redactions) ;
345
345
let e: Vec < _ > = expected. lines ( ) . map ( |line| WildStr :: new ( line) ) . collect ( ) ;
346
- let a: Vec < _ > = actual. lines ( ) . map ( |line| WildStr :: new ( line ) ) . collect ( ) ;
346
+ let a: Vec < _ > = actual. lines ( ) . collect ( ) ;
347
347
if e. len ( ) == 0 {
348
348
bail ! ( "expected length must not be zero" ) ;
349
349
}
350
350
for window in a. windows ( e. len ( ) ) {
351
- if window == e {
351
+ if e == window {
352
352
return Ok ( ( ) ) ;
353
353
}
354
354
}
@@ -407,7 +407,6 @@ pub(crate) fn match_with_without(
407
407
408
408
let matches: Vec < _ > = actual
409
409
. lines ( )
410
- . map ( WildStr :: new)
411
410
. filter ( |line| with_wild. iter ( ) . all ( |with| with == line) )
412
411
. filter ( |line| !without_wild. iter ( ) . any ( |without| without == line) )
413
412
. collect ( ) ;
@@ -472,13 +471,12 @@ impl<'a> WildStr<'a> {
472
471
}
473
472
}
474
473
475
- impl < ' a > PartialEq for WildStr < ' a > {
476
- fn eq ( & self , other : & Self ) -> bool {
477
- match ( self . has_meta , other. has_meta ) {
478
- ( false , false ) => self . line == other. line ,
479
- ( true , false ) => meta_cmp ( self . line , other. line ) ,
480
- ( false , true ) => meta_cmp ( other. line , self . line ) ,
481
- ( true , true ) => panic ! ( "both lines cannot have [..]" ) ,
474
+ impl PartialEq < & str > for WildStr < ' _ > {
475
+ fn eq ( & self , other : & & str ) -> bool {
476
+ if self . has_meta {
477
+ meta_cmp ( self . line , other)
478
+ } else {
479
+ self . line == * other
482
480
}
483
481
}
484
482
}
@@ -666,10 +664,10 @@ mod test {
666
664
( "[..]" , "a b" ) ,
667
665
( "[..]b" , "a b" ) ,
668
666
] {
669
- assert_eq ! ( WildStr :: new( a) , WildStr :: new ( b ) ) ;
667
+ assert_eq ! ( WildStr :: new( a) , b ) ;
670
668
}
671
669
for ( a, b) in & [ ( "[..]b" , "c" ) , ( "b" , "c" ) , ( "b" , "cb" ) ] {
672
- assert_ne ! ( WildStr :: new( a) , WildStr :: new ( b ) ) ;
670
+ assert_ne ! ( WildStr :: new( a) , b ) ;
673
671
}
674
672
}
675
673
0 commit comments