Skip to content

Commit

Permalink
Add example doc for ToOwned trait
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Apr 5, 2016
1 parent 7fd331e commit 6fee337
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/libcollections/borrow.rs
Expand Up @@ -49,6 +49,18 @@ pub trait ToOwned {
type Owned: Borrow<Self>;

/// Creates owned data from borrowed data, usually by cloning.
///
/// # Examples
///
/// Basic usage:
///
/// ```
/// let s = "a"; // &str
/// let ss = s.to_owned(); // String
///
/// let v = &[1, 2]; // slice
/// let vv = v.to_owned(); // Vec
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
fn to_owned(&self) -> Self::Owned;
}
Expand Down

0 comments on commit 6fee337

Please sign in to comment.