diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2015-03-21 06:02:56 -0400 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2015-03-23 18:05:20 -0400 |
| commit | 76ead081088d7cc88a4686210b72b60ae12bd7a8 (patch) | |
| tree | 05148b9c3c1c91227e68f92b4b0d70d95dbdc1cb /src/libcore | |
| parent | 8bd8466e812e7c5acb99a50493e45aeb1bb81e93 (diff) | |
| download | rust-76ead081088d7cc88a4686210b72b60ae12bd7a8.tar.gz rust-76ead081088d7cc88a4686210b72b60ae12bd7a8.zip | |
Remove auto-deref'ing Pattern impl because it conflicts with other
possible blanket impls and also triggers internal overflow. Add some special cases for common uses (&&str, &String) for now; bounds-targeting deref coercions are probably the right longer term answer.
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)); -} |
