From 283f6762caebb723a17ce82e1fc120928697cfb9 Mon Sep 17 00:00:00 2001 From: Simon Sapin Date: Mon, 8 Jul 2019 17:50:27 +0200 Subject: Take separator by value in `[T]::join` --- src/liballoc/slice.rs | 10 +++++----- src/liballoc/str.rs | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/liballoc') diff --git a/src/liballoc/slice.rs b/src/liballoc/slice.rs index d7a9f83ad24..1b18dbeda9c 100644 --- a/src/liballoc/slice.rs +++ b/src/liballoc/slice.rs @@ -510,7 +510,7 @@ impl [T] { /// 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(&self, sep: &Separator) -> >::Output + pub fn join(&self, sep: Separator) -> >::Output where Self: Join { Join::join(self, sep) @@ -528,7 +528,7 @@ impl [T] { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[rustc_deprecated(since = "1.3.0", reason = "renamed to join")] - pub fn connect(&self, sep: &Separator) -> >::Output + pub fn connect(&self, sep: Separator) -> >::Output where Self: Join { Join::join(self, sep) @@ -620,14 +620,14 @@ pub trait Concat { /// Helper trait for [`[T]::join`](../../std/primitive.slice.html#method.join) #[unstable(feature = "slice_concat_trait", issue = "27747")] -pub trait Join { +pub trait Join { #[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 @@ impl> Concat for [V] { } #[unstable(feature = "slice_concat_ext", issue = "27747")] -impl> Join for [V] { +impl> Join<&'_ T> for [V] { type Output = Vec; fn join(slice: &Self, sep: &T) -> Vec { diff --git a/src/liballoc/str.rs b/src/liballoc/str.rs index 726ac1907fa..f57cf96a641 100644 --- a/src/liballoc/str.rs +++ b/src/liballoc/str.rs @@ -83,7 +83,7 @@ impl> Concat for [S] { } #[unstable(feature = "slice_concat_ext", issue = "27747")] -impl> Join for [S] { +impl> Join<&'_ str> for [S] { type Output = String; fn join(slice: &Self, sep: &str) -> String { -- cgit 1.4.1-3-g733a5