Rename SliceConcatExt::connect to join

This commit is contained in:
Wesley Wiser 2015-07-09 23:08:34 -04:00
parent 072d07ce9f
commit 29c0c956bf
2 changed files with 22 additions and 2 deletions
src/libcollections

@ -1025,6 +1025,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 = "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.
///
@ -1034,6 +1045,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;
}
@ -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

@ -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)
}
}
/*