From 6fee337b10107e421fee0ca580f0feba224dbb93 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 5 Apr 2016 14:11:08 +0200 Subject: [PATCH] Add example doc for ToOwned trait --- src/libcollections/borrow.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/libcollections/borrow.rs b/src/libcollections/borrow.rs index 0e92676cf971b..6ca0db68a88ce 100644 --- a/src/libcollections/borrow.rs +++ b/src/libcollections/borrow.rs @@ -49,6 +49,18 @@ pub trait ToOwned { type Owned: Borrow; /// 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; }