diff options
| author | kennytm <kennytm@gmail.com> | 2018-09-07 13:47:17 +0800 |
|---|---|---|
| committer | kennytm <kennytm@gmail.com> | 2018-09-07 18:13:42 +0800 |
| commit | 03de1c44d12123d28c15f263ba83fdeebccb6cb8 (patch) | |
| tree | 99d497843021aaf355f5c0f0f7040e590a0cd9b3 | |
| parent | d2a0f98159422de62ab201c45447ac94871ba71b (diff) | |
| parent | 0e62990760c0cd4032463dd9024a3dbd16a8de8a (diff) | |
| download | rust-03de1c44d12123d28c15f263ba83fdeebccb6cb8.tar.gz rust-03de1c44d12123d28c15f263ba83fdeebccb6cb8.zip | |
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.
| -rw-r--r-- | src/libcore/mem.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index e00a22bf8b6..1803adee3c1 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -971,14 +971,16 @@ impl<T> ManuallyDrop<T> { 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 /// /// ```rust /// use std::mem::ManuallyDrop; /// 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")] #[inline] @@ -990,11 +992,15 @@ impl<T> ManuallyDrop<T> { impl<T: ?Sized> ManuallyDrop<T> { /// Manually drops the contained value. /// + /// If you have ownership of the value, you can use [`ManuallyDrop::into_inner`] instead. + /// /// # Safety /// /// 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 /// uninitialized data is not actually used. + /// + /// [`ManuallyDrop::into_inner`]: #method.into_inner #[stable(feature = "manually_drop", since = "1.20.0")] #[inline] pub unsafe fn drop(slot: &mut ManuallyDrop<T>) { |
