From c9f600bceeb5086ea292c3872ee3094ce770f9b0 Mon Sep 17 00:00:00 2001 From: Aaron Turon Date: Thu, 26 Mar 2015 17:47:13 -0700 Subject: [PATCH] Stabilize some stragglers in `std::option` 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] --- src/libcore/option.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/libcore/option.rs b/src/libcore/option.rs index a565b137cc85..8bc2bf423a10 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -480,7 +480,7 @@ impl Option { /// assert_eq!(x.ok_or(0), Err(0)); /// ``` #[inline] - #[unstable(feature = "core")] + #[stable(feature = "rust1", since = "1.0.0")] pub fn ok_or(self, err: E) -> Result { match self { Some(v) => Ok(v), @@ -502,7 +502,7 @@ impl Option { /// 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>(self, err: F) -> Result { match self { Some(v) => Ok(v), @@ -548,8 +548,7 @@ impl Option { /// 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 { IterMut { inner: Item { opt: self.as_mut() } } } @@ -721,13 +720,11 @@ impl Option { } } -impl<'a, T: Clone, D: Deref> Option { - /// Maps an Option to an Option by dereffing and cloning the contents of the Option. - /// Useful for converting an Option<&T> to an Option. - #[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 by cloning the contents of the Option. + #[stable(feature = "rust1", since = "1.0.0")] pub fn cloned(self) -> Option { - self.map(|t| t.deref().clone()) + self.map(|t| t.clone()) } }