From a9dbb7908dd851dff81f613452518db3ba04887c Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Mon, 15 Dec 2014 16:40:27 -0600 Subject: [PATCH] Add a doctest for the string Add function. --- src/libcollections/string.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index c4659f86680..3dd24fc33ae 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -857,6 +857,16 @@ fn equiv(&self, other: &S) -> bool { #[experimental = "waiting on Add stabilization"] impl Add 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()); -- 2.44.0