Skip to content

Commit ec0cb57

Browse files
authored
Rollup merge of #73336 - lzutao:pattern-group, r=sfackler
Group `Pattern::strip_*` method together
2 parents 5193c5d + d82dd43 commit ec0cb57

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/libcore/str/pattern.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ use crate::slice::memchr;
6969
/// |--------------------------|-------------------------------------------|
7070
/// | `&str` | is substring |
7171
/// | `char` | is contained in string |
72-
/// | `&[char] | any char in slice is contained in string |
72+
/// | `&[char]` | any char in slice is contained in string |
7373
/// | `F: FnMut(char) -> bool` | `F` returns `true` for a char in string |
7474
/// | `&&str` | is substring |
7575
/// | `&String` | is substring |
@@ -117,6 +117,15 @@ pub trait Pattern<'a>: Sized {
117117
matches!(self.into_searcher(haystack).next(), SearchStep::Match(0, _))
118118
}
119119

120+
/// Checks whether the pattern matches at the back of the haystack
121+
#[inline]
122+
fn is_suffix_of(self, haystack: &'a str) -> bool
123+
where
124+
Self::Searcher: ReverseSearcher<'a>,
125+
{
126+
matches!(self.into_searcher(haystack).next_back(), SearchStep::Match(_, j) if haystack.len() == j)
127+
}
128+
120129
/// Removes the pattern from the front of haystack, if it matches.
121130
#[inline]
122131
fn strip_prefix_of(self, haystack: &'a str) -> Option<&'a str> {
@@ -133,15 +142,6 @@ pub trait Pattern<'a>: Sized {
133142
}
134143
}
135144

136-
/// Checks whether the pattern matches at the back of the haystack
137-
#[inline]
138-
fn is_suffix_of(self, haystack: &'a str) -> bool
139-
where
140-
Self::Searcher: ReverseSearcher<'a>,
141-
{
142-
matches!(self.into_searcher(haystack).next_back(), SearchStep::Match(_, j) if haystack.len() == j)
143-
}
144-
145145
/// Removes the pattern from the back of haystack, if it matches.
146146
#[inline]
147147
fn strip_suffix_of(self, haystack: &'a str) -> Option<&'a str>

0 commit comments

Comments
 (0)