Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add a doctest for the string Add function.
  • Loading branch information
jbranchaud committed Dec 15, 2014
commit a9dbb7908dd851dff81f613452518db3ba04887c
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