From de7fefa04c74ecaa7618c910a74ae1cf62affa8e Mon Sep 17 00:00:00 2001 From: Andrea Canciani Date: Thu, 12 Dec 2019 21:09:17 +0100 Subject: [PATCH] Minor cleanup in `Pattern::{is_prefix_of,is_suffix_of}` for `char` --- src/libcore/str/pattern.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/libcore/str/pattern.rs b/src/libcore/str/pattern.rs index 71dd77fee73..1b6e6f1c2e4 100644 --- a/src/libcore/str/pattern.rs +++ b/src/libcore/str/pattern.rs @@ -450,15 +450,13 @@ impl<'a> Pattern<'a> for char { #[inline] fn is_prefix_of(self, haystack: &'a str) -> bool { - let mut buffer = [0u8; 4]; - self.encode_utf8(&mut buffer).is_prefix_of(haystack) + self.encode_utf8(&mut [0u8; 4]).is_prefix_of(haystack) } #[inline] fn is_suffix_of(self, haystack: &'a str) -> bool where Self::Searcher: ReverseSearcher<'a> { - let mut buffer = [0u8; 4]; - self.encode_utf8(&mut buffer).is_suffix_of(haystack) + self.encode_utf8(&mut [0u8; 4]).is_suffix_of(haystack) } }