mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Rollup merge of #32744 - GuillaumeGomez:patch-3, r=steveklabnik
Add example doc for ToOwned trait Fixes #29342. r? @steveklabnik
This commit is contained in:
commit
510b380317
@ -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