about summary refs log tree commit diff
diff options
context:
space:
mode:
authorWesley Wiser <wwiser@gmail.com>2015-07-09 23:08:34 -0400
committerWesley Wiser <wwiser@gmail.com>2015-07-10 19:40:46 -0400
commit29c0c956bf8ba9d6cdb1723d40685514bc9c17ef (patch)
treecd0f3e31bd843c65966f45ff3609ba32407c0a4e
parent072d07ce9fc85728a62664ce674e26c54a759da5 (diff)
downloadrust-29c0c956bf8ba9d6cdb1723d40685514bc9c17ef.tar.gz
rust-29c0c956bf8ba9d6cdb1723d40685514bc9c17ef.zip
Rename SliceConcatExt::connect to join #26900
-rw-r--r--src/libcollections/slice.rs18
-rw-r--r--src/libcollections/str.rs6
2 files changed, 22 insertions, 2 deletions
diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs
index d49463911e6..c4d9ef844eb 100644
--- a/src/libcollections/slice.rs
+++ b/src/libcollections/slice.rs
@@ -1031,9 +1031,21 @@ pub trait SliceConcatExt<T: ?Sized> {
     /// # Examples
     ///
     /// ```
+    /// assert_eq!(["hello", "world"].join(" "), "hello world");
+    /// ```
+    #[stable(feature = "rust1", since = "1.0.0")]
+    fn join(&self, sep: &T) -> Self::Output;
+
+    /// Flattens a slice of `T` into a single value `Self::Output`, placing a
+    /// given separator between each.
+    ///
+    /// # Examples
+    ///
+    /// ```
     /// assert_eq!(["hello", "world"].connect(" "), "hello world");
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
+    #[deprecated(since = "1.3.0", reason = "renamed to join")]
     fn connect(&self, sep: &T) -> Self::Output;
 }
 
@@ -1049,7 +1061,7 @@ impl<T: Clone, V: Borrow<[T]>> SliceConcatExt<T> for [V] {
         result
     }
 
-    fn connect(&self, sep: &T) -> Vec<T> {
+    fn join(&self, sep: &T) -> Vec<T> {
         let size = self.iter().fold(0, |acc, v| acc + v.borrow().len());
         let mut result = Vec::with_capacity(size + self.len());
         let mut first = true;
@@ -1059,6 +1071,10 @@ impl<T: Clone, V: Borrow<[T]>> SliceConcatExt<T> for [V] {
         }
         result
     }
+
+    fn connect(&self, sep: &T) -> Vec<T> {
+        self.join(sep)
+    }
 }
 
 /// An iterator that yields the element swaps needed to produce
diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs
index 7e72ad1569a..7e4a219fc42 100644
--- a/src/libcollections/str.rs
+++ b/src/libcollections/str.rs
@@ -105,7 +105,7 @@ impl<S: Borrow<str>> SliceConcatExt<str> for [S] {
         result
     }
 
-    fn connect(&self, sep: &str) -> String {
+    fn join(&self, sep: &str) -> String {
         if self.is_empty() {
             return String::new();
         }
@@ -132,6 +132,10 @@ impl<S: Borrow<str>> SliceConcatExt<str> for [S] {
         }
         result
     }
+
+    fn connect(&self, sep: &str) -> String {
+        self.join(sep)
+    }
 }
 
 /*