about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libcore/str/pattern.rs14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/libcore/str/pattern.rs b/src/libcore/str/pattern.rs
index dd3765d42da..71dd77fee73 100644
--- a/src/libcore/str/pattern.rs
+++ b/src/libcore/str/pattern.rs
@@ -450,21 +450,15 @@ impl<'a> Pattern<'a> for char {
 
     #[inline]
     fn is_prefix_of(self, haystack: &'a str) -> bool {
-        if let Some(ch) = haystack.chars().next() {
-            self == ch
-        } else {
-            false
-        }
+        let mut buffer = [0u8; 4];
+        self.encode_utf8(&mut buffer).is_prefix_of(haystack)
     }
 
     #[inline]
     fn is_suffix_of(self, haystack: &'a str) -> bool where Self::Searcher: ReverseSearcher<'a>
     {
-        if let Some(ch) = haystack.chars().next_back() {
-            self == ch
-        } else {
-            false
-        }
+        let mut buffer = [0u8; 4];
+        self.encode_utf8(&mut buffer).is_suffix_of(haystack)
     }
 }