]> git.lizzy.rs Git - rust.git/blobdiff - src/libcollections/slice.rs
Auto merge of #26957 - wesleywiser:rename_connect_to_join, r=alexcrichton
[rust.git] / src / libcollections / slice.rs
index 0933734ee383f4cc4fab56874164b9b89da241da..f5a27565ef7dec67a8ddb7a1e750478470d96122 100644 (file)
@@ -1056,6 +1056,17 @@ pub trait SliceConcatExt<T: ?Sized> {
     #[stable(feature = "rust1", since = "1.0.0")]
     fn concat(&self) -> Self::Output;
 
+    /// Flattens a slice of `T` into a single value `Self::Output`, placing a
+    /// given separator between each.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// assert_eq!(["hello", "world"].join(" "), "hello world");
+    /// ```
+    #[stable(feature = "rename_connect_to_join", since = "1.3.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.
     ///
@@ -1065,6 +1076,7 @@ pub trait SliceConcatExt<T: ?Sized> {
     /// 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;
 }
 
@@ -1080,7 +1092,7 @@ fn concat(&self) -> Vec<T> {
         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;
@@ -1090,6 +1102,10 @@ fn connect(&self, sep: &T) -> Vec<T> {
         }
         result
     }
+
+    fn connect(&self, sep: &T) -> Vec<T> {
+        self.join(sep)
+    }
 }
 
 /// An iterator that yields the element swaps needed to produce