Skip to content

Commit dd67e55

Browse files
committed
Changed std::pattern::Pattern impl on &'a &'a str to &'a &'b str
in order to allow a bit more felixibility in how to use it.
1 parent 0a52494 commit dd67e55

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/libcollectionstest/str.rs

+13
Original file line numberDiff line numberDiff line change
@@ -1508,6 +1508,19 @@ generate_iterator_test! {
15081508
with str::rsplitn;
15091509
}
15101510

1511+
#[test]
1512+
fn different_str_pattern_forwarding_lifetimes() {
1513+
use std::str::pattern::Pattern;
1514+
1515+
fn foo<'a, P>(p: P) where for<'b> &'b P: Pattern<'a> {
1516+
for _ in 0..3 {
1517+
"asdf".find(&p);
1518+
}
1519+
}
1520+
1521+
foo::<&str>("x");
1522+
}
1523+
15111524
mod bench {
15121525
use test::{Bencher, black_box};
15131526

src/libcore/str/pattern.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ impl<'a, F> Pattern<'a> for F where F: FnMut(char) -> bool {
492492
/////////////////////////////////////////////////////////////////////////////
493493

494494
/// Delegates to the `&str` impl.
495-
impl<'a, 'b> Pattern<'a> for &'b &'b str {
495+
impl<'a, 'b, 'c> Pattern<'a> for &'c &'b str {
496496
pattern_methods!(StrSearcher<'a, 'b>, |&s| s, |s| s);
497497
}
498498

0 commit comments

Comments
 (0)