Stablize RefCell::{replace, swap}

RefCell::replace_with is not stablized in this PR, since it wasn't part of the RFC.
This commit is contained in:
Michael Howell 2017-12-05 09:07:12 -07:00 committed by GitHub
parent a2899408dd
commit fd064e041a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -584,7 +584,6 @@ impl<T> RefCell<T> {
/// # Examples
///
/// ```
/// #![feature(refcell_replace_swap)]
/// use std::cell::RefCell;
/// let cell = RefCell::new(5);
/// let old_value = cell.replace(6);
@ -592,7 +591,7 @@ impl<T> RefCell<T> {
/// assert_eq!(cell, RefCell::new(6));
/// ```
#[inline]
#[unstable(feature = "refcell_replace_swap", issue="43570")]
#[stable(feature = "refcell_replace_swap", since="1.24.0")]
pub fn replace(&self, t: T) -> T {
mem::replace(&mut *self.borrow_mut(), t)
}
@ -636,7 +635,6 @@ impl<T> RefCell<T> {
/// # Examples
///
/// ```
/// #![feature(refcell_replace_swap)]
/// use std::cell::RefCell;
/// let c = RefCell::new(5);
/// let d = RefCell::new(6);
@ -645,7 +643,7 @@ impl<T> RefCell<T> {
/// assert_eq!(d, RefCell::new(5));
/// ```
#[inline]
#[unstable(feature = "refcell_replace_swap", issue="43570")]
#[stable(feature = "refcell_replace_swap", since="1.24.0")]
pub fn swap(&self, other: &Self) {
mem::swap(&mut *self.borrow_mut(), &mut *other.borrow_mut())
}