Skip to content

Commit 9d1dbd9

Browse files
committed
Merge pull request #19895 from jbranchaud/add-string-add-doctest
Add a doctest for the string Add function. Reviewed-by: steveklabnik
2 parents e300d72 + a9dbb79 commit 9d1dbd9

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
@@ -859,6 +859,16 @@ impl<'a, S: Str> Equiv<S> for String {
859859
#[cfg(stage0)]
860860
#[experimental = "waiting on Add stabilization"]
861861
impl<S: Str> Add<S, String> for String {
862+
/// Concatenates `self` and `other` as a new mutable `String`.
863+
///
864+
/// # Examples
865+
///
866+
/// ```
867+
/// let string1 = "foo".to_string();
868+
/// let string2 = "bar".to_string();
869+
/// let string3 = string1 + string2;
870+
/// assert_eq!(string3, "foobar".to_string());
871+
/// ```
862872
fn add(&self, other: &S) -> String {
863873
let mut s = String::from_str(self.as_slice());
864874
s.push_str(other.as_slice());

0 commit comments

Comments
 (0)