Skip to content

Commit

Permalink
Merge pull request #19895 from jbranchaud/add-string-add-doctest
Browse files Browse the repository at this point in the history
Add a doctest for the string Add function.

Reviewed-by: steveklabnik
  • Loading branch information
bors committed Dec 16, 2014
2 parents 7415b78 + a9dbb79 commit b76dd4c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/libcollections/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -859,6 +859,16 @@ impl<'a, S: Str> Equiv<S> for String {
#[cfg(stage0)]
#[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());
Expand Down

0 comments on commit b76dd4c

Please sign in to comment.