提交 6fee337b 编写于 作者: G Guillaume Gomez

Add example doc for ToOwned trait

上级 7fd331e1
...@@ -49,6 +49,18 @@ pub trait ToOwned { ...@@ -49,6 +49,18 @@ pub trait ToOwned {
type Owned: Borrow<Self>; type Owned: Borrow<Self>;
/// Creates owned data from borrowed data, usually by cloning. /// 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")] #[stable(feature = "rust1", since = "1.0.0")]
fn to_owned(&self) -> Self::Owned; fn to_owned(&self) -> Self::Owned;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册