mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-23 12:40:14 +03:00
Rollup merge of #46517 - notriddle:patch-2, r=BurntSushi
Stablize RefCell::{replace, swap}
RefCell::replace_with is not stablized in this PR, since it wasn't part of the RFC.
CC #43570
This commit is contained in:
+2
-4
@@ -584,7 +584,6 @@ pub fn into_inner(self) -> 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 @@ pub fn into_inner(self) -> T {
|
||||
/// assert_eq!(cell, RefCell::new(6));
|
||||
/// ```
|
||||
#[inline]
|
||||
#[unstable(feature = "refcell_replace_swap", issue="43570")]
|
||||
#[stable(feature = "refcell_replace", since="1.24.0")]
|
||||
pub fn replace(&self, t: T) -> T {
|
||||
mem::replace(&mut *self.borrow_mut(), t)
|
||||
}
|
||||
@@ -636,7 +635,6 @@ pub fn replace_with<F: FnOnce(&mut T) -> T>(&self, f: F) -> T {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// #![feature(refcell_replace_swap)]
|
||||
/// use std::cell::RefCell;
|
||||
/// let c = RefCell::new(5);
|
||||
/// let d = RefCell::new(6);
|
||||
@@ -645,7 +643,7 @@ pub fn replace_with<F: FnOnce(&mut T) -> T>(&self, f: F) -> T {
|
||||
/// assert_eq!(d, RefCell::new(5));
|
||||
/// ```
|
||||
#[inline]
|
||||
#[unstable(feature = "refcell_replace_swap", issue="43570")]
|
||||
#[stable(feature = "refcell_swap", since="1.24.0")]
|
||||
pub fn swap(&self, other: &Self) {
|
||||
mem::swap(&mut *self.borrow_mut(), &mut *other.borrow_mut())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user