diff options
| author | Jubilee <workingjubilee@gmail.com> | 2024-10-24 15:53:35 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-24 15:53:35 -0700 |
| commit | 96ae9d4703ed017c555b852cbd58efdf412fa805 (patch) | |
| tree | 8891e4b937424ca843d15ad895856c59f7821abf | |
| parent | abfad21c973e30a3949916149ac4db5fe8691cf9 (diff) | |
| parent | 689101f8a3ea26f70902b10ab99b9860f565d9dc (diff) | |
| download | rust-96ae9d4703ed017c555b852cbd58efdf412fa805.tar.gz rust-96ae9d4703ed017c555b852cbd58efdf412fa805.zip | |
Rollup merge of #132113 - LaihoE:pattern_as_utf8_default_impl, r=workingjubilee
Provide a default impl for Pattern::as_utf8_pattern Newly added ```Pattern::as_utf8_pattern()``` causes needless breakage for crates that implement Pattern. This provides a default implementation instead. r? `@BurntSushi`
| -rw-r--r-- | library/core/src/str/pattern.rs | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/library/core/src/str/pattern.rs b/library/core/src/str/pattern.rs index eb60effe813..f68465c9bda 100644 --- a/library/core/src/str/pattern.rs +++ b/library/core/src/str/pattern.rs @@ -162,7 +162,9 @@ pub trait Pattern: Sized { } /// Returns the pattern as utf-8 bytes if possible. - fn as_utf8_pattern(&self) -> Option<Utf8Pattern<'_>>; + fn as_utf8_pattern(&self) -> Option<Utf8Pattern<'_>> { + None + } } /// Result of calling [`Pattern::as_utf8_pattern()`]. /// Can be used for inspecting the contents of a [`Pattern`] in cases @@ -675,11 +677,6 @@ impl<C: MultiCharEq> Pattern for MultiCharEqPattern<C> { fn into_searcher(self, haystack: &str) -> MultiCharEqSearcher<'_, C> { MultiCharEqSearcher { haystack, char_eq: self.0, char_indices: haystack.char_indices() } } - - #[inline] - fn as_utf8_pattern(&self) -> Option<Utf8Pattern<'_>> { - None - } } unsafe impl<'a, C: MultiCharEq> Searcher<'a> for MultiCharEqSearcher<'a, C> { @@ -770,11 +767,6 @@ macro_rules! pattern_methods { { ($pmap)(self).strip_suffix_of(haystack) } - - #[inline] - fn as_utf8_pattern(&self) -> Option<Utf8Pattern<'_>> { - None - } }; } |
