about summary refs log tree commit diff
path: root/library/core/src/str/pattern.rs
diff options
context:
space:
mode:
authorHTGAzureX1212 <39023054+HTGAzureX1212@users.noreply.github.com>2024-02-02 20:49:20 +0800
committerHTGAzureX1212 <39023054+HTGAzureX1212@users.noreply.github.com>2025-02-16 21:08:38 +0800
commiteec49bbf59c922060a5785a47d885529e6cb2ac8 (patch)
tree07dfb9a29f4561e401de15ad0ac593165ff0c476 /library/core/src/str/pattern.rs
parenta5db378dc14a40dd1580c27fb8362156446382c3 (diff)
downloadrust-eec49bbf59c922060a5785a47d885529e6cb2ac8.tar.gz
rust-eec49bbf59c922060a5785a47d885529e6cb2ac8.zip
add MAX_LEN_UTF8 and MAX_LEN_UTF16 constants
Diffstat (limited to 'library/core/src/str/pattern.rs')
-rw-r--r--library/core/src/str/pattern.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/library/core/src/str/pattern.rs b/library/core/src/str/pattern.rs
index 52e2364893e..2d941adfd85 100644
--- a/library/core/src/str/pattern.rs
+++ b/library/core/src/str/pattern.rs
@@ -38,6 +38,7 @@
     issue = "27721"
 )]
 
+use crate::char::MAX_LEN_UTF8;
 use crate::cmp::Ordering;
 use crate::convert::TryInto as _;
 use crate::slice::memchr;
@@ -561,8 +562,8 @@ impl Pattern for char {
     type Searcher<'a> = CharSearcher<'a>;
 
     #[inline]
-    fn into_searcher(self, haystack: &str) -> Self::Searcher<'_> {
-        let mut utf8_encoded = [0; 4];
+    fn into_searcher<'a>(self, haystack: &'a str) -> Self::Searcher<'a> {
+        let mut utf8_encoded = [0; MAX_LEN_UTF8];
         let utf8_size = self
             .encode_utf8(&mut utf8_encoded)
             .len()