diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-03-23 15:10:30 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-03-23 15:10:30 -0700 |
| commit | bed77408df6b279d1d3b67c07e77c8d40e496f2e (patch) | |
| tree | d3ab43eb7ec3c750c241a5cd95f6b919cbe68075 /src/libcore | |
| parent | 9e347b39f105a2ab416fc518ee51225882a6d996 (diff) | |
| parent | 76ead081088d7cc88a4686210b72b60ae12bd7a8 (diff) | |
| download | rust-bed77408df6b279d1d3b67c07e77c8d40e496f2e.tar.gz rust-bed77408df6b279d1d3b67c07e77c8d40e496f2e.zip | |
rollup merge of #23580: nikomatsakis/pattern-and-overflow
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/str/pattern.rs | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/src/libcore/str/pattern.rs b/src/libcore/str/pattern.rs index 7bf248917a5..98b6533980d 100644 --- a/src/libcore/str/pattern.rs +++ b/src/libcore/str/pattern.rs @@ -474,22 +474,16 @@ impl<'a, 'b> Pattern<'a> for &'b [char] { s, CharEqPattern(s)); } +/// A convenience impl that delegates to the impl for `&str` +impl<'a, 'b> Pattern<'a> for &'b &'b str { + type Searcher = <&'b str as Pattern<'a>>::Searcher; + associated_items!(<&'b str as Pattern<'a>>::Searcher, + s, (*s)); +} + /// Searches for chars that match the given predicate impl<'a, F> Pattern<'a> for F where F: FnMut(char) -> bool { type Searcher = <CharEqPattern<Self> as Pattern<'a>>::Searcher; associated_items!(<CharEqPattern<Self> as Pattern<'a>>::Searcher, s, CharEqPattern(s)); } - -// Deref-forward impl - -use ops::Deref; - -/// Delegates to the next deref coercion of `Self` that implements `Pattern` -impl<'a, 'b, P: 'b + ?Sized, T: Deref<Target = P> + ?Sized> Pattern<'a> for &'b T - where &'b P: Pattern<'a> -{ - type Searcher = <&'b P as Pattern<'a>>::Searcher; - associated_items!(<&'b P as Pattern<'a>>::Searcher, - s, (&**s)); -} |
