Skip to content

Commit

Permalink
Changed std::pattern::Pattern impl on &'a &'a str to &'a &'b str
Browse files Browse the repository at this point in the history
in order to allow a bit more felixibility in how to use it.
  • Loading branch information
Kimundi committed Mar 1, 2016
1 parent 0a52494 commit dd67e55
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 13 additions & 0 deletions src/libcollectionstest/str.rs
Expand Up @@ -1508,6 +1508,19 @@ generate_iterator_test! {
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};

Expand Down
2 changes: 1 addition & 1 deletion src/libcore/str/pattern.rs
Expand Up @@ -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);
}

Expand Down

0 comments on commit dd67e55

Please sign in to comment.