]> git.lizzy.rs Git - rust.git/commitdiff
Changed `std::pattern::Pattern` impl on `&'a &'a str` to `&'a &'b str`
authorMarvin Löbel <loebel.marvin@gmail.com>
Tue, 1 Mar 2016 16:53:51 +0000 (17:53 +0100)
committerMarvin Löbel <loebel.marvin@gmail.com>
Tue, 1 Mar 2016 16:53:51 +0000 (17:53 +0100)
in order to allow a bit more felixibility in how to use it.

src/libcollectionstest/str.rs
src/libcore/str/pattern.rs

index 25457043a9df45dd5a5274ae83e9c184b351a240..b84b37dbf752cdb8467804368b67e90d8dcab552 100644 (file)
@@ -1508,6 +1508,19 @@ fn $name() {
     with str::rsplitn;
 }
 
+#[test]
+fn different_str_pattern_forwarding_lifetimes() {
+    use std::str::pattern::Pattern;
+
+    fn foo<'a, P>(p: P) where for<'b> &'b P: Pattern<'a> {
+        for _ in 0..3 {
+            "asdf".find(&p);
+        }
+    }
+
+    foo::<&str>("x");
+}
+
 mod bench {
     use test::{Bencher, black_box};
 
index 29130100e996fe5268c28c173de8aff97e74ae7f..abad29cb7751eda4c5662f917312cf4e8bed3623 100644 (file)
@@ -492,7 +492,7 @@ impl<'a, F> Pattern<'a> for F where F: FnMut(char) -> bool {
 /////////////////////////////////////////////////////////////////////////////
 
 /// Delegates to the `&str` impl.
-impl<'a, 'b> Pattern<'a> for &'b &'b str {
+impl<'a, 'b, 'c> Pattern<'a> for &'c &'b str {
     pattern_methods!(StrSearcher<'a, 'b>, |&s| s, |s| s);
 }