1
Fork 0

Rollup merge of #31989 - Kimundi:more_flexible_str_pattern_indirection, r=bluss

This allows a bit more flexibility in how to use it, see the included test case.
This commit is contained in:
Manish Goregaokar 2016-03-02 07:01:15 +05:30
commit fe565954ea
2 changed files with 14 additions and 1 deletions

View file

@ -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};

View 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);
}