]> git.lizzy.rs Git - rust.git/commitdiff
add doc examples for connect/concat
authorSteve Klabnik <steve@steveklabnik.com>
Wed, 21 Jan 2015 22:56:33 +0000 (17:56 -0500)
committerSteve Klabnik <steve@steveklabnik.com>
Wed, 21 Jan 2015 22:56:33 +0000 (17:56 -0500)
src/libcollections/slice.rs

index 988ec4c661faae229e2951dea5effe788c05d686..681173b4ce1abbb8181f697a93bc6a3013532f29 100644 (file)
@@ -993,11 +993,30 @@ fn into_vec(mut self: Box<Self>) -> Vec<T> {
 /// An extension trait for concatenating slices
 pub trait SliceConcatExt<T: ?Sized, U> {
     /// 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;
 }