Add example doc for ToOwned trait

This commit is contained in:
Guillaume Gomez 2016-04-05 14:11:08 +02:00
parent 7fd331e166
commit 6fee337b10

View File

@ -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;
}