Skip to content

Commit

Permalink
stabalize ManuallyDrop::take
Browse files Browse the repository at this point in the history
  • Loading branch information
CAD97 committed Jan 9, 2020
1 parent c404ce6 commit 4e98966
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
15 changes: 8 additions & 7 deletions src/libcore/mem/manually_drop.rs
Expand Up @@ -87,27 +87,28 @@ impl<T> ManuallyDrop<T> {
slot.value
}

/// Takes the contained value out.
/// Takes the value from the `ManuallyDrop<T>` container out.
///
/// This method is primarily intended for moving out values in drop.
/// Instead of using [`ManuallyDrop::drop`] to manually drop the value,
/// you can use this method to take the value and use it however desired.
/// `Drop` will be invoked on the returned value following normal end-of-scope rules.
///
/// If you have ownership of the container, you can use [`ManuallyDrop::into_inner`] instead.
/// Whenever possible, it is preferrable to use [`into_inner`][`ManuallyDrop::into_inner`]
/// instead, which prevents duplicating the content of the `ManuallyDrop<T>`.
///
/// # Safety
///
/// This function semantically moves out the contained value without preventing further usage.
/// It is up to the user of this method to ensure that this container is not used again.
/// This function semantically moves out the contained value without preventing further usage,
/// leaving the state of this container unchanged.
/// It is your responsibility to ensure that this `ManuallyDrop` is not used again.
///
/// [`ManuallyDrop::drop`]: #method.drop
/// [`ManuallyDrop::into_inner`]: #method.into_inner
#[must_use = "if you don't need the value, you can use `ManuallyDrop::drop` instead"]
#[unstable(feature = "manually_drop_take", issue = "55422")]
#[stable(feature = "manually_drop_take", since = "1.42.0")]
#[inline]
pub unsafe fn take(slot: &mut ManuallyDrop<T>) -> T {
ManuallyDrop::into_inner(ptr::read(slot))
ptr::read(&slot.value)
}
}

Expand Down
1 change: 0 additions & 1 deletion src/libstd/lib.rs
Expand Up @@ -275,7 +275,6 @@
#![feature(link_args)]
#![feature(linkage)]
#![feature(log_syntax)]
#![feature(manually_drop_take)]
#![feature(maybe_uninit_ref)]
#![feature(maybe_uninit_slice)]
#![feature(needs_panic_runtime)]
Expand Down

0 comments on commit 4e98966

Please sign in to comment.