Skip to content

Commit 45f1324

Browse files
committed
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
2 parents a491d21 + c9f600b commit 45f1324

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

src/libcore/option.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ impl<T> Option<T> {
480480
/// assert_eq!(x.ok_or(0), Err(0));
481481
/// ```
482482
#[inline]
483-
#[unstable(feature = "core")]
483+
#[stable(feature = "rust1", since = "1.0.0")]
484484
pub fn ok_or<E>(self, err: E) -> Result<T, E> {
485485
match self {
486486
Some(v) => Ok(v),
@@ -502,7 +502,7 @@ impl<T> Option<T> {
502502
/// assert_eq!(x.ok_or_else(|| 0), Err(0));
503503
/// ```
504504
#[inline]
505-
#[unstable(feature = "core")]
505+
#[stable(feature = "rust1", since = "1.0.0")]
506506
pub fn ok_or_else<E, F: FnOnce() -> E>(self, err: F) -> Result<T, E> {
507507
match self {
508508
Some(v) => Ok(v),
@@ -548,8 +548,7 @@ impl<T> Option<T> {
548548
/// assert_eq!(x.iter_mut().next(), None);
549549
/// ```
550550
#[inline]
551-
#[unstable(feature = "core",
552-
reason = "waiting for iterator conventions")]
551+
#[stable(feature = "rust1", since = "1.0.0")]
553552
pub fn iter_mut(&mut self) -> IterMut<T> {
554553
IterMut { inner: Item { opt: self.as_mut() } }
555554
}
@@ -721,13 +720,11 @@ impl<T> Option<T> {
721720
}
722721
}
723722

724-
impl<'a, T: Clone, D: Deref<Target=T>> Option<D> {
725-
/// Maps an Option<D> to an Option<T> by dereffing and cloning the contents of the Option.
726-
/// Useful for converting an Option<&T> to an Option<T>.
727-
#[unstable(feature = "core",
728-
reason = "recently added as part of collections reform")]
723+
impl<'a, T: Clone> Option<&'a T> {
724+
/// Maps an Option<&T> to an Option<T> by cloning the contents of the Option.
725+
#[stable(feature = "rust1", since = "1.0.0")]
729726
pub fn cloned(self) -> Option<T> {
730-
self.map(|t| t.deref().clone())
727+
self.map(|t| t.clone())
731728
}
732729
}
733730

0 commit comments

Comments
 (0)