diff options
| author | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2016-04-05 14:11:08 +0200 |
|---|---|---|
| committer | Guillaume Gomez <guillaume1.gomez@gmail.com> | 2016-04-05 14:11:08 +0200 |
| commit | 6fee337b10107e421fee0ca580f0feba224dbb93 (patch) | |
| tree | 560fed277dabb0f6a7c9ea3afda81411a4e2c483 /src | |
| parent | 7fd331e16642363c333804fe3322ae6bc0be8fbc (diff) | |
| download | rust-6fee337b10107e421fee0ca580f0feba224dbb93.tar.gz rust-6fee337b10107e421fee0ca580f0feba224dbb93.zip | |
Add example doc for ToOwned trait
Diffstat (limited to 'src')
| -rw-r--r-- | src/libcollections/borrow.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/libcollections/borrow.rs b/src/libcollections/borrow.rs index 0e92676cf97..6ca0db68a88 100644 --- a/src/libcollections/borrow.rs +++ b/src/libcollections/borrow.rs @@ -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; } |
