diff options
| author | Igor Aleksanov <popzxc@yandex.ru> | 2020-01-07 10:35:16 +0300 |
|---|---|---|
| committer | Igor Aleksanov <popzxc@yandex.ru> | 2020-01-08 07:10:28 +0300 |
| commit | f720469fd0c4dff6d92e2f778ea2f252f76dcc2e (patch) | |
| tree | eed0768e1946a78b266025d661016f190795d871 /src/libcore/str | |
| parent | aa0769b92e60f5298f0b6326b8654c9b04351b98 (diff) | |
| download | rust-f720469fd0c4dff6d92e2f778ea2f252f76dcc2e.tar.gz rust-f720469fd0c4dff6d92e2f778ea2f252f76dcc2e.zip | |
Use matches macro in libcore and libstd
Diffstat (limited to 'src/libcore/str')
| -rw-r--r-- | src/libcore/str/pattern.rs | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/src/libcore/str/pattern.rs b/src/libcore/str/pattern.rs index 2cbdeb2e4ee..46d9499394a 100644 --- a/src/libcore/str/pattern.rs +++ b/src/libcore/str/pattern.rs @@ -46,10 +46,7 @@ pub trait Pattern<'a>: Sized { /// Checks whether the pattern matches at the front of the haystack #[inline] fn is_prefix_of(self, haystack: &'a str) -> bool { - match self.into_searcher(haystack).next() { - SearchStep::Match(0, _) => true, - _ => false, - } + matches!(self.into_searcher(haystack).next(), SearchStep::Match(0, _)) } /// Checks whether the pattern matches at the back of the haystack @@ -58,10 +55,7 @@ pub trait Pattern<'a>: Sized { where Self::Searcher: ReverseSearcher<'a>, { - match self.into_searcher(haystack).next_back() { - SearchStep::Match(_, j) if haystack.len() == j => true, - _ => false, - } + matches!(self.into_searcher(haystack).next_back(), SearchStep::Match(_, j) if haystack.len() == j) } } |
