Skip to content

Commit

Permalink
Add a doctest for the string Add function.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbranchaud committed Dec 15, 2014
1 parent 92e9e70 commit a9dbb79
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 @@ -857,6 +857,16 @@ impl<'a, S: Str> Equiv<S> for String {

#[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 a9dbb79

Please sign in to comment.