diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-03-27 10:07:52 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-03-27 10:07:52 -0700 |
| commit | 45f1324037b098d6e92da7b34cc0aba274fdae97 (patch) | |
| tree | b4fd78fabcd37ea532a6c8ae00af5f3f52c3c7c2 /src/libcore | |
| parent | a491d2135386a53c6e5dd4545ad46b0868ea4721 (diff) | |
| parent | c9f600bceeb5086ea292c3872ee3094ce770f9b0 (diff) | |
| download | rust-45f1324037b098d6e92da7b34cc0aba274fdae97.tar.gz rust-45f1324037b098d6e92da7b34cc0aba274fdae97.zip | |
rollup merge of #23771: aturon/stab-straggle-1
Marks as `#[stable}`: * `ok_or` * `ok_or_else` * `iter_mut` * `cloned` Similarly to `IteratorExt::cloned`, the `cloned` method is pared down to work only on `Option<&T>`. Thus, this is a: [breaking-change] r? @alexcrichton
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/option.rs | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 623fcc56e6a..368d56f515e 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -480,7 +480,7 @@ impl<T> Option<T> { /// assert_eq!(x.ok_or(0), Err(0)); /// ``` #[inline] - #[unstable(feature = "core")] + #[stable(feature = "rust1", since = "1.0.0")] pub fn ok_or<E>(self, err: E) -> Result<T, E> { match self { Some(v) => Ok(v), @@ -502,7 +502,7 @@ impl<T> Option<T> { /// assert_eq!(x.ok_or_else(|| 0), Err(0)); /// ``` #[inline] - #[unstable(feature = "core")] + #[stable(feature = "rust1", since = "1.0.0")] pub fn ok_or_else<E, F: FnOnce() -> E>(self, err: F) -> Result<T, E> { match self { Some(v) => Ok(v), @@ -548,8 +548,7 @@ impl<T> Option<T> { /// assert_eq!(x.iter_mut().next(), None); /// ``` #[inline] - #[unstable(feature = "core", - reason = "waiting for iterator conventions")] + #[stable(feature = "rust1", since = "1.0.0")] pub fn iter_mut(&mut self) -> IterMut<T> { IterMut { inner: Item { opt: self.as_mut() } } } @@ -721,13 +720,11 @@ impl<T> Option<T> { } } -impl<'a, T: Clone, D: Deref<Target=T>> Option<D> { - /// Maps an Option<D> to an Option<T> by dereffing and cloning the contents of the Option. - /// Useful for converting an Option<&T> to an Option<T>. - #[unstable(feature = "core", - reason = "recently added as part of collections reform")] +impl<'a, T: Clone> Option<&'a T> { + /// Maps an Option<&T> to an Option<T> by cloning the contents of the Option. + #[stable(feature = "rust1", since = "1.0.0")] pub fn cloned(self) -> Option<T> { - self.map(|t| t.deref().clone()) + self.map(|t| t.clone()) } } |
