mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 08:44:35 +00:00
Add example doc for ToOwned trait
This commit is contained in:
parent
7fd331e166
commit
6fee337b10
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user