Skip to content

Commit a9dbb79

Browse files
committed
Add a doctest for the string Add function.
1 parent 92e9e70 commit a9dbb79

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/libcollections/string.rs

+10
Original file line numberDiff line numberDiff line change
@@ -857,6 +857,16 @@ impl<'a, S: Str> Equiv<S> for String {
857857

858858
#[experimental = "waiting on Add stabilization"]
859859
impl<S: Str> Add<S, String> for String {
860+
/// Concatenates `self` and `other` as a new mutable `String`.
861+
///
862+
/// # Examples
863+
///
864+
/// ```
865+
/// let string1 = "foo".to_string();
866+
/// let string2 = "bar".to_string();
867+
/// let string3 = string1 + string2;
868+
/// assert_eq!(string3, "foobar".to_string());
869+
/// ```
860870
fn add(&self, other: &S) -> String {
861871
let mut s = String::from_str(self.as_slice());
862872
s.push_str(other.as_slice());

0 commit comments

Comments
 (0)