about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2016-04-05 14:11:08 +0200
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2016-04-05 14:11:08 +0200
commit6fee337b10107e421fee0ca580f0feba224dbb93 (patch)
tree560fed277dabb0f6a7c9ea3afda81411a4e2c483 /src
parent7fd331e16642363c333804fe3322ae6bc0be8fbc (diff)
downloadrust-6fee337b10107e421fee0ca580f0feba224dbb93.tar.gz
rust-6fee337b10107e421fee0ca580f0feba224dbb93.zip
Add example doc for ToOwned trait
Diffstat (limited to 'src')
-rw-r--r--src/libcollections/borrow.rs12
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;
 }