about summary refs log tree commit diff
path: root/src/libcollectionstest
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-01-13 08:15:45 +0000
committerbors <bors@rust-lang.org>2016-01-13 08:15:45 +0000
commit8796e012cbfa0bf63522e409edc10cbac5afaacd (patch)
tree9c7831f26abfe80fc99be28be9b394134ed3b907 /src/libcollectionstest
parentf1bcfdd8e48ce9ca322e800a3641c65a9b1c1a5d (diff)
parent34fe201c1a6370a945398fda58c192cd4921afb0 (diff)
Auto merge of #29498 - wthrowe:replace-pattern, r=alexcrichton
It appears this was left out of RFC rust-lang/rfcs#528 because it might be useful to
also generalize the second argument in some way.  That doesn't seem to
prevent generalizing the first argument now, however.

This is a [breaking-change] because it could cause type-inference to
fail where it previously succeeded.

Also update docs for a few other methods that still referred to `&str` instead of patterns.
Diffstat (limited to 'src/libcollectionstest')
-rw-r--r--src/libcollectionstest/str.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libcollectionstest/str.rs b/src/libcollectionstest/str.rs
index e22ff7ca540..4d84855ddf9 100644
--- a/src/libcollectionstest/str.rs
+++ b/src/libcollectionstest/str.rs
@@ -270,6 +270,15 @@ fn test_replace_2d() {
 }
 
 #[test]
+fn test_replace_pattern() {
+    let data = "abcdαβγδabcdαβγδ";
+    assert_eq!(data.replace("dαβ", "😺😺😺"), "abc😺😺😺γδabc😺😺😺γδ");
+    assert_eq!(data.replace('γ', "😺😺😺"), "abcdαβ😺😺😺δabcdαβ😺😺😺δ");
+    assert_eq!(data.replace(&['a', 'γ'] as &[_], "😺😺😺"), "😺😺😺bcdαβ😺😺😺δ😺😺😺bcdαβ😺😺😺δ");
+    assert_eq!(data.replace(|c| c == 'γ', "😺😺😺"), "abcdαβ😺😺😺δabcdαβ😺😺😺δ");
+}
+
+#[test]
 fn test_slice() {
     assert_eq!("ab", &"abc"[0..2]);
     assert_eq!("bc", &"abc"[1..3]);