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