Rollup merge of #53946 - tbu-:pr_doc_manuallydrop, r=cramertj
Clarify `ManuallyDrop` docs Mention that you can use `into_inner` to drop the contained value.
This commit is contained in:
commit
03de1c44d1
1 changed files with 8 additions and 2 deletions
|
@ -971,14 +971,16 @@ impl<T> ManuallyDrop<T> {
|
||||||
ManuallyDrop { value }
|
ManuallyDrop { value }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Extract the value from the ManuallyDrop container.
|
/// Extract the value from the `ManuallyDrop` container.
|
||||||
|
///
|
||||||
|
/// This allows the value to be dropped again.
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// use std::mem::ManuallyDrop;
|
/// use std::mem::ManuallyDrop;
|
||||||
/// let x = ManuallyDrop::new(Box::new(()));
|
/// let x = ManuallyDrop::new(Box::new(()));
|
||||||
/// let _: Box<()> = ManuallyDrop::into_inner(x);
|
/// let _: Box<()> = ManuallyDrop::into_inner(x); // This drops the `Box`.
|
||||||
/// ```
|
/// ```
|
||||||
#[stable(feature = "manually_drop", since = "1.20.0")]
|
#[stable(feature = "manually_drop", since = "1.20.0")]
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -990,11 +992,15 @@ impl<T> ManuallyDrop<T> {
|
||||||
impl<T: ?Sized> ManuallyDrop<T> {
|
impl<T: ?Sized> ManuallyDrop<T> {
|
||||||
/// Manually drops the contained value.
|
/// Manually drops the contained value.
|
||||||
///
|
///
|
||||||
|
/// If you have ownership of the value, you can use [`ManuallyDrop::into_inner`] instead.
|
||||||
|
///
|
||||||
/// # Safety
|
/// # Safety
|
||||||
///
|
///
|
||||||
/// This function runs the destructor of the contained value and thus the wrapped value
|
/// This function runs the destructor of the contained value and thus the wrapped value
|
||||||
/// now represents uninitialized data. It is up to the user of this method to ensure the
|
/// now represents uninitialized data. It is up to the user of this method to ensure the
|
||||||
/// uninitialized data is not actually used.
|
/// uninitialized data is not actually used.
|
||||||
|
///
|
||||||
|
/// [`ManuallyDrop::into_inner`]: #method.into_inner
|
||||||
#[stable(feature = "manually_drop", since = "1.20.0")]
|
#[stable(feature = "manually_drop", since = "1.20.0")]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub unsafe fn drop(slot: &mut ManuallyDrop<T>) {
|
pub unsafe fn drop(slot: &mut ManuallyDrop<T>) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue