Skip to content

Commit 29c0c95

Browse files
committed
Rename SliceConcatExt::connect to join #26900
1 parent 072d07c commit 29c0c95

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/libcollections/slice.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1025,6 +1025,17 @@ pub trait SliceConcatExt<T: ?Sized> {
10251025
#[stable(feature = "rust1", since = "1.0.0")]
10261026
fn concat(&self) -> Self::Output;
10271027

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+
10281039
/// Flattens a slice of `T` into a single value `Self::Output`, placing a
10291040
/// given separator between each.
10301041
///
@@ -1034,6 +1045,7 @@ pub trait SliceConcatExt<T: ?Sized> {
10341045
/// assert_eq!(["hello", "world"].connect(" "), "hello world");
10351046
/// ```
10361047
#[stable(feature = "rust1", since = "1.0.0")]
1048+
#[deprecated(since = "1.3.0", reason = "renamed to join")]
10371049
fn connect(&self, sep: &T) -> Self::Output;
10381050
}
10391051

@@ -1049,7 +1061,7 @@ impl<T: Clone, V: Borrow<[T]>> SliceConcatExt<T> for [V] {
10491061
result
10501062
}
10511063

1052-
fn connect(&self, sep: &T) -> Vec<T> {
1064+
fn join(&self, sep: &T) -> Vec<T> {
10531065
let size = self.iter().fold(0, |acc, v| acc + v.borrow().len());
10541066
let mut result = Vec::with_capacity(size + self.len());
10551067
let mut first = true;
@@ -1059,6 +1071,10 @@ impl<T: Clone, V: Borrow<[T]>> SliceConcatExt<T> for [V] {
10591071
}
10601072
result
10611073
}
1074+
1075+
fn connect(&self, sep: &T) -> Vec<T> {
1076+
self.join(sep)
1077+
}
10621078
}
10631079

10641080
/// An iterator that yields the element swaps needed to produce

src/libcollections/str.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl<S: Borrow<str>> SliceConcatExt<str> for [S] {
105105
result
106106
}
107107

108-
fn connect(&self, sep: &str) -> String {
108+
fn join(&self, sep: &str) -> String {
109109
if self.is_empty() {
110110
return String::new();
111111
}
@@ -132,6 +132,10 @@ impl<S: Borrow<str>> SliceConcatExt<str> for [S] {
132132
}
133133
result
134134
}
135+
136+
fn connect(&self, sep: &str) -> String {
137+
self.join(sep)
138+
}
135139
}
136140

137141
/*

0 commit comments

Comments
 (0)