Skip to content

Commit

Permalink
Stabilize move_cell feature, closes rust-lang#39264
Browse files Browse the repository at this point in the history
  • Loading branch information
aturon committed Mar 15, 2017
1 parent fd182c4 commit f23d448
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/libcore/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,6 @@ impl<T> Cell<T> {
/// # Examples
///
/// ```
/// #![feature(move_cell)]
/// use std::cell::Cell;
///
/// let c1 = Cell::new(5i32);
Expand All @@ -404,7 +403,7 @@ impl<T> Cell<T> {
/// assert_eq!(5, c2.get());
/// ```
#[inline]
#[unstable(feature = "move_cell", issue = "39264")]
#[stable(feature = "move_cell", since = "1.17.0")]
pub fn swap(&self, other: &Self) {
if ptr::eq(self, other) {
return;
Expand All @@ -419,15 +418,14 @@ impl<T> Cell<T> {
/// # Examples
///
/// ```
/// #![feature(move_cell)]
/// use std::cell::Cell;
///
/// let c = Cell::new(5);
/// let old = c.replace(10);
///
/// assert_eq!(5, old);
/// ```
#[unstable(feature = "move_cell", issue = "39264")]
#[stable(feature = "move_cell", since = "1.17.0")]
pub fn replace(&self, val: T) -> T {
mem::replace(unsafe { &mut *self.value.get() }, val)
}
Expand All @@ -437,15 +435,14 @@ impl<T> Cell<T> {
/// # Examples
///
/// ```
/// #![feature(move_cell)]
/// use std::cell::Cell;
///
/// let c = Cell::new(5);
/// let five = c.into_inner();
///
/// assert_eq!(five, 5);
/// ```
#[unstable(feature = "move_cell", issue = "39264")]
#[stable(feature = "move_cell", since = "1.17.0")]
pub fn into_inner(self) -> T {
unsafe { self.value.into_inner() }
}
Expand All @@ -457,7 +454,6 @@ impl<T: Default> Cell<T> {
/// # Examples
///
/// ```
/// #![feature(move_cell)]
/// use std::cell::Cell;
///
/// let c = Cell::new(5);
Expand All @@ -466,7 +462,7 @@ impl<T: Default> Cell<T> {
/// assert_eq!(five, 5);
/// assert_eq!(c.into_inner(), 0);
/// ```
#[unstable(feature = "move_cell", issue = "39264")]
#[stable(feature = "move_cell", since = "1.17.0")]
pub fn take(&self) -> T {
self.replace(Default::default())
}
Expand Down

0 comments on commit f23d448

Please sign in to comment.