@@ -1025,6 +1025,17 @@ pub trait SliceConcatExt<T: ?Sized> {
1025
1025
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1026
1026
fn concat ( & self ) -> Self :: Output ;
1027
1027
1028
+ /// Flattens a slice of `T` into a single value `Self::Output`, placing a
1029
+ /// given separator between each.
1030
+ ///
1031
+ /// # Examples
1032
+ ///
1033
+ /// ```
1034
+ /// assert_eq!(["hello", "world"].join(" "), "hello world");
1035
+ /// ```
1036
+ #[ stable( feature = "rust1" , since = "1.0.0" ) ]
1037
+ fn join ( & self , sep : & T ) -> Self :: Output ;
1038
+
1028
1039
/// Flattens a slice of `T` into a single value `Self::Output`, placing a
1029
1040
/// given separator between each.
1030
1041
///
@@ -1034,6 +1045,7 @@ pub trait SliceConcatExt<T: ?Sized> {
1034
1045
/// assert_eq!(["hello", "world"].connect(" "), "hello world");
1035
1046
/// ```
1036
1047
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
1048
+ #[ deprecated( since = "1.3.0" , reason = "renamed to join" ) ]
1037
1049
fn connect ( & self , sep : & T ) -> Self :: Output ;
1038
1050
}
1039
1051
@@ -1049,7 +1061,7 @@ impl<T: Clone, V: Borrow<[T]>> SliceConcatExt<T> for [V] {
1049
1061
result
1050
1062
}
1051
1063
1052
- fn connect ( & self , sep : & T ) -> Vec < T > {
1064
+ fn join ( & self , sep : & T ) -> Vec < T > {
1053
1065
let size = self . iter ( ) . fold ( 0 , |acc, v| acc + v. borrow ( ) . len ( ) ) ;
1054
1066
let mut result = Vec :: with_capacity ( size + self . len ( ) ) ;
1055
1067
let mut first = true ;
@@ -1059,6 +1071,10 @@ impl<T: Clone, V: Borrow<[T]>> SliceConcatExt<T> for [V] {
1059
1071
}
1060
1072
result
1061
1073
}
1074
+
1075
+ fn connect ( & self , sep : & T ) -> Vec < T > {
1076
+ self . join ( sep)
1077
+ }
1062
1078
}
1063
1079
1064
1080
/// An iterator that yields the element swaps needed to produce
0 commit comments