diff options
| author | Lzu Tao <taolzu@gmail.com> | 2020-06-14 01:01:07 +0000 |
|---|---|---|
| committer | Lzu Tao <taolzu@gmail.com> | 2020-06-14 01:01:07 +0000 |
| commit | d82dd43387fef192714047ec0169ecd15f8b250a (patch) | |
| tree | 673755bc5d61deec412eaf07b9570903136bacda /src/libcore | |
| parent | 06e47688bf15d0215edbe05b21603062f6d2eb5d (diff) | |
| download | rust-d82dd43387fef192714047ec0169ecd15f8b250a.tar.gz rust-d82dd43387fef192714047ec0169ecd15f8b250a.zip | |
Group Pattern::strip_* method together
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/str/pattern.rs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/libcore/str/pattern.rs b/src/libcore/str/pattern.rs index 263d6b5efdf..14f1f293d40 100644 --- a/src/libcore/str/pattern.rs +++ b/src/libcore/str/pattern.rs @@ -69,7 +69,7 @@ use crate::slice::memchr; /// |--------------------------|-------------------------------------------| /// | `&str` | is substring | /// | `char` | is contained in string | -/// | `&[char] | any char in slice is contained in string | +/// | `&[char]` | any char in slice is contained in string | /// | `F: FnMut(char) -> bool` | `F` returns `true` for a char in string | /// | `&&str` | is substring | /// | `&String` | is substring | @@ -117,6 +117,15 @@ pub trait Pattern<'a>: Sized { matches!(self.into_searcher(haystack).next(), SearchStep::Match(0, _)) } + /// Checks whether the pattern matches at the back of the haystack + #[inline] + fn is_suffix_of(self, haystack: &'a str) -> bool + where + Self::Searcher: ReverseSearcher<'a>, + { + matches!(self.into_searcher(haystack).next_back(), SearchStep::Match(_, j) if haystack.len() == j) + } + /// Removes the pattern from the front of haystack, if it matches. #[inline] fn strip_prefix_of(self, haystack: &'a str) -> Option<&'a str> { @@ -133,15 +142,6 @@ pub trait Pattern<'a>: Sized { } } - /// Checks whether the pattern matches at the back of the haystack - #[inline] - fn is_suffix_of(self, haystack: &'a str) -> bool - where - Self::Searcher: ReverseSearcher<'a>, - { - matches!(self.into_searcher(haystack).next_back(), SearchStep::Match(_, j) if haystack.len() == j) - } - /// Removes the pattern from the back of haystack, if it matches. #[inline] fn strip_suffix_of(self, haystack: &'a str) -> Option<&'a str> |
