Skip to content

Commit

Permalink
Rollup merge of rust-lang#38090 - GuillaumeGomez:option_doc, r=frewsxcv
Browse files Browse the repository at this point in the history
Add cloned example for Option

r? @frewsxcv
  • Loading branch information
dns2utf8 authored Dec 1, 2016
2 parents 464faa1 + 8e6ae19 commit 0c28d5d
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/libcore/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,16 @@ impl<T> Option<T> {
impl<'a, T: Clone> Option<&'a T> {
/// Maps an `Option<&T>` to an `Option<T>` by cloning the contents of the
/// option.
///
/// # Examples
///
/// ```
/// let x = 12;
/// let opt_x = Some(&x);
/// assert_eq!(opt_x, Some(&12));
/// let cloned = opt_x.cloned();
/// assert_eq!(cloned, Some(12));
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
pub fn cloned(self) -> Option<T> {
self.map(|t| t.clone())
Expand Down

0 comments on commit 0c28d5d

Please sign in to comment.