Skip to content

Commit

Permalink
Unrolled build for rust-lang#132113
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#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`
  • Loading branch information
rust-timer authored Oct 25, 2024
2 parents 3dc1b9f + 689101f commit 35906b3
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions library/core/src/str/pattern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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> {
Expand Down Expand Up @@ -770,11 +767,6 @@ macro_rules! pattern_methods {
{
($pmap)(self).strip_suffix_of(haystack)
}

#[inline]
fn as_utf8_pattern(&self) -> Option<Utf8Pattern<'_>> {
None
}
};
}

Expand Down

0 comments on commit 35906b3

Please sign in to comment.