Take separator by value in [T]::join

This commit is contained in:
Simon Sapin
2019-07-08 17:50:27 +02:00
parent 01d93bf595
commit 283f6762ca
2 changed files with 6 additions and 6 deletions
+5 -5
View File
@@ -510,7 +510,7 @@ pub fn concat<Item: ?Sized>(&self) -> <Self as Concat<Item>>::Output
/// assert_eq!([[1, 2], [3, 4]].join(&0), [1, 2, 0, 3, 4]);
/// ```
#[stable(feature = "rename_connect_to_join", since = "1.3.0")]
pub fn join<Separator: ?Sized>(&self, sep: &Separator) -> <Self as Join<Separator>>::Output
pub fn join<Separator>(&self, sep: Separator) -> <Self as Join<Separator>>::Output
where Self: Join<Separator>
{
Join::join(self, sep)
@@ -528,7 +528,7 @@ pub fn join<Separator: ?Sized>(&self, sep: &Separator) -> <Self as Join<Separato
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_deprecated(since = "1.3.0", reason = "renamed to join")]
pub fn connect<Separator: ?Sized>(&self, sep: &Separator) -> <Self as Join<Separator>>::Output
pub fn connect<Separator>(&self, sep: Separator) -> <Self as Join<Separator>>::Output
where Self: Join<Separator>
{
Join::join(self, sep)
@@ -620,14 +620,14 @@ pub trait Concat<Item: ?Sized> {
/// Helper trait for [`[T]::join`](../../std/primitive.slice.html#method.join)
#[unstable(feature = "slice_concat_trait", issue = "27747")]
pub trait Join<Separator: ?Sized> {
pub trait Join<Separator> {
#[unstable(feature = "slice_concat_trait", issue = "27747")]
/// The resulting type after concatenation
type Output;
/// Implementation of [`[T]::join`](../../std/primitive.slice.html#method.join)
#[unstable(feature = "slice_concat_trait", issue = "27747")]
fn join(slice: &Self, sep: &Separator) -> Self::Output;
fn join(slice: &Self, sep: Separator) -> Self::Output;
}
#[unstable(feature = "slice_concat_ext", issue = "27747")]
@@ -645,7 +645,7 @@ fn concat(slice: &Self) -> Vec<T> {
}
#[unstable(feature = "slice_concat_ext", issue = "27747")]
impl<T: Clone, V: Borrow<[T]>> Join<T> for [V] {
impl<T: Clone, V: Borrow<[T]>> Join<&'_ T> for [V] {
type Output = Vec<T>;
fn join(slice: &Self, sep: &T) -> Vec<T> {
+1 -1
View File
@@ -83,7 +83,7 @@ fn concat(slice: &Self) -> String {
}
#[unstable(feature = "slice_concat_ext", issue = "27747")]
impl<S: Borrow<str>> Join<str> for [S] {
impl<S: Borrow<str>> Join<&'_ str> for [S] {
type Output = String;
fn join(slice: &Self, sep: &str) -> String {