about summary refs log tree commit diff
diff options
context:
space:
mode:
-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;
 }