diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index 729b0ebc3ce7..8eb7995c4221 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -996,9 +996,13 @@ impl [T] { //////////////////////////////////////////////////////////////////////////////// // Extension traits for slices over specific kinds of data //////////////////////////////////////////////////////////////////////////////// -#[unstable(feature = "collections", reason = "U should be an associated type")] +#[unstable(feature = "collections", reason = "recently changed")] /// An extension trait for concatenating slices -pub trait SliceConcatExt { +pub trait SliceConcatExt { + #[unstable(feature = "collections", reason = "recently changed")] + /// The resulting type after concatenation + type Output; + /// Flattens a slice of `T` into a single value `U`. /// /// # Examples @@ -1007,7 +1011,7 @@ pub trait SliceConcatExt { /// assert_eq!(["hello", "world"].concat(), "helloworld"); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - fn concat(&self) -> U; + fn concat(&self) -> Self::Output; /// Flattens a slice of `T` into a single value `U`, placing a given separator between each. /// @@ -1017,10 +1021,12 @@ pub trait SliceConcatExt { /// assert_eq!(["hello", "world"].connect(" "), "hello world"); /// ``` #[stable(feature = "rust1", since = "1.0.0")] - fn connect(&self, sep: &T) -> U; + fn connect(&self, sep: &T) -> Self::Output; } -impl> SliceConcatExt> for [V] { +impl> SliceConcatExt for [V] { + type Output = Vec; + fn concat(&self) -> Vec { let size = self.iter().fold(0, |acc, v| acc + v.as_ref().len()); let mut result = Vec::with_capacity(size); diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index 38431ab5bf1b..da1b4dcddfc3 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -83,7 +83,9 @@ pub use core::str::pattern; Section: Creating a string */ -impl> SliceConcatExt for [S] { +impl> SliceConcatExt for [S] { + type Output = String; + fn concat(&self) -> String { if self.is_empty() { return String::new();