File tree 1 file changed +4
-5
lines changed
1 file changed +4
-5
lines changed Original file line number Diff line number Diff line change @@ -513,17 +513,16 @@ impl<'a, 'b> Pattern<'a> for &'b str {
513
513
/// Checks whether the pattern matches at the front of the haystack
514
514
#[ inline]
515
515
fn is_prefix_of ( self , haystack : & ' a str ) -> bool {
516
- // Use `as_bytes` so that we can slice through a character in the haystack.
517
- // Since self is always valid UTF-8, this can't result in a false positive.
518
- self . len ( ) <= haystack. len ( ) &&
519
- self . as_bytes ( ) == & haystack. as_bytes ( ) [ ..self . len ( ) ]
516
+ haystack. is_char_boundary ( self . len ( ) ) &&
517
+ self == & haystack[ ..self . len ( ) ]
520
518
}
521
519
522
520
/// Checks whether the pattern matches at the back of the haystack
523
521
#[ inline]
524
522
fn is_suffix_of ( self , haystack : & ' a str ) -> bool {
525
523
self . len ( ) <= haystack. len ( ) &&
526
- self . as_bytes ( ) == & haystack. as_bytes ( ) [ haystack. len ( ) - self . len ( ) ..]
524
+ haystack. is_char_boundary ( haystack. len ( ) - self . len ( ) ) &&
525
+ self == & haystack[ haystack. len ( ) - self . len ( ) ..]
527
526
}
528
527
}
529
528
You can’t perform that action at this time.
0 commit comments