]> git.lizzy.rs Git - rust.git/commitdiff
Add a doctest for the string Add function.
authorjbranchaud <jbranchaud@gmail.com>
Mon, 15 Dec 2014 22:40:27 +0000 (16:40 -0600)
committerjbranchaud <jbranchaud@gmail.com>
Mon, 15 Dec 2014 22:40:27 +0000 (16:40 -0600)
src/libcollections/string.rs

index c4659f86680e4426b1cafc8c76cc3a6b240ca114..3dd24fc33ae517ca3742e1666c4703a59d11d7a1 100644 (file)
@@ -857,6 +857,16 @@ fn equiv(&self, other: &S) -> bool {
 
 #[experimental = "waiting on Add stabilization"]
 impl<S: Str> Add<S, String> for String {
+    /// Concatenates `self` and `other` as a new mutable `String`.
+    ///
+    /// # Examples
+    ///
+    /// ```
+    /// let string1 = "foo".to_string();
+    /// let string2 = "bar".to_string();
+    /// let string3 = string1 + string2;
+    /// assert_eq!(string3, "foobar".to_string());
+    /// ```
     fn add(&self, other: &S) -> String {
         let mut s = String::from_str(self.as_slice());
         s.push_str(other.as_slice());