diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index 8c7f79d4d78..f65802de5ac 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -967,11 +967,30 @@ impl SliceExt for [T] { /// An extension trait for concatenating slices pub trait SliceConcatExt { /// Flattens a slice of `T` into a single value `U`. + /// + /// # Examples + /// + /// ``` + /// let v = vec!["hello", "world"]; + /// + /// let s: String = v.concat(); + /// + /// println!("{}", s); // prints "helloworld" + /// ``` #[stable] fn concat(&self) -> U; - /// Flattens a slice of `T` into a single value `U`, placing a - /// given separator between each. + /// Flattens a slice of `T` into a single value `U`, placing a given separator between each. + /// + /// # Examples + /// + /// ``` + /// let v = vec!["hello", "world"]; + /// + /// let s: String = v.connect(" "); + /// + /// println!("{}", s); // prints "hello world" + /// ``` #[stable] fn connect(&self, sep: &T) -> U; }