Skip to content

Commit 285fd48

Browse files
committed
---
yaml --- r: 191983 b: refs/heads/snap-stage3 c: 76ead08 h: refs/heads/master i: 191981: 570c294 191979: 840081a 191975: cfcb16f 191967: 9c3e39a v: v3
1 parent e269d20 commit 285fd48

File tree

4 files changed

+28
-16
lines changed

4 files changed

+28
-16
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 809a554fca2d0ebc2ba50077016fe282a4064752
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 8bd8466e812e7c5acb99a50493e45aeb1bb81e93
4+
refs/heads/snap-stage3: 76ead081088d7cc88a4686210b72b60ae12bd7a8
55
refs/heads/try: ce76bff75603a754d092456285ff455eb871633d
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d

branches/snap-stage3/src/libcollections/string.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use core::mem;
2525
use core::ops::{self, Deref, Add, Index};
2626
use core::ptr;
2727
use core::slice;
28+
use core::str::Pattern;
2829
use unicode::str as unicode_str;
2930
use unicode::str::Utf16Item;
3031

@@ -765,6 +766,25 @@ impl<'a> Extend<&'a str> for String {
765766
}
766767
}
767768

769+
/// A convenience impl that delegates to the impl for `&str`
770+
impl<'a, 'b> Pattern<'a> for &'b String {
771+
type Searcher = <&'b str as Pattern<'a>>::Searcher;
772+
773+
fn into_searcher(self, haystack: &'a str) -> <&'b str as Pattern<'a>>::Searcher {
774+
self[..].into_searcher(haystack)
775+
}
776+
777+
#[inline]
778+
fn is_contained_in(self, haystack: &'a str) -> bool {
779+
self[..].is_contained_in(haystack)
780+
}
781+
782+
#[inline]
783+
fn is_prefix_of(self, haystack: &'a str) -> bool {
784+
self[..].is_prefix_of(haystack)
785+
}
786+
}
787+
768788
#[stable(feature = "rust1", since = "1.0.0")]
769789
impl PartialEq for String {
770790
#[inline]

branches/snap-stage3/src/libcore/str/pattern.rs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -474,22 +474,16 @@ impl<'a, 'b> Pattern<'a> for &'b [char] {
474474
s, CharEqPattern(s));
475475
}
476476

477+
/// A convenience impl that delegates to the impl for `&str`
478+
impl<'a, 'b> Pattern<'a> for &'b &'b str {
479+
type Searcher = <&'b str as Pattern<'a>>::Searcher;
480+
associated_items!(<&'b str as Pattern<'a>>::Searcher,
481+
s, (*s));
482+
}
483+
477484
/// Searches for chars that match the given predicate
478485
impl<'a, F> Pattern<'a> for F where F: FnMut(char) -> bool {
479486
type Searcher = <CharEqPattern<Self> as Pattern<'a>>::Searcher;
480487
associated_items!(<CharEqPattern<Self> as Pattern<'a>>::Searcher,
481488
s, CharEqPattern(s));
482489
}
483-
484-
// Deref-forward impl
485-
486-
use ops::Deref;
487-
488-
/// Delegates to the next deref coercion of `Self` that implements `Pattern`
489-
impl<'a, 'b, P: 'b + ?Sized, T: Deref<Target = P> + ?Sized> Pattern<'a> for &'b T
490-
where &'b P: Pattern<'a>
491-
{
492-
type Searcher = <&'b P as Pattern<'a>>::Searcher;
493-
associated_items!(<&'b P as Pattern<'a>>::Searcher,
494-
s, (&**s));
495-
}

branches/snap-stage3/src/libcoretest/str.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ fn test_pattern_deref_forward() {
1313
let data = "aabcdaa";
1414
assert!(data.contains("bcd"));
1515
assert!(data.contains(&"bcd"));
16-
assert!(data.contains(&&"bcd"));
1716
assert!(data.contains(&"bcd".to_string()));
18-
assert!(data.contains(&&"bcd".to_string()));
1917
}
2018

2119
#[test]

0 commit comments

Comments
 (0)