We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent cc863f0 commit 1f6d023Copy full SHA for 1f6d023
src/libcore/str/pattern.rs
@@ -450,21 +450,15 @@ impl<'a> Pattern<'a> for char {
450
451
#[inline]
452
fn is_prefix_of(self, haystack: &'a str) -> bool {
453
- if let Some(ch) = haystack.chars().next() {
454
- self == ch
455
- } else {
456
- false
457
- }
+ let mut buffer = [0u8; 4];
+ self.encode_utf8(&mut buffer).is_prefix_of(haystack)
458
}
459
460
461
fn is_suffix_of(self, haystack: &'a str) -> bool where Self::Searcher: ReverseSearcher<'a>
462
{
463
- if let Some(ch) = haystack.chars().next_back() {
464
465
466
467
+ self.encode_utf8(&mut buffer).is_suffix_of(haystack)
468
469
470
0 commit comments