diff options
| author | Tobias Bucher <tobiasbucher5991@gmail.com> | 2018-09-04 14:43:21 +0200 |
|---|---|---|
| committer | Tobias Bucher <tobiasbucher5991@gmail.com> | 2018-09-04 14:43:21 +0200 |
| commit | 0e62990760c0cd4032463dd9024a3dbd16a8de8a (patch) | |
| tree | 7d708cb464fdfcb20006811958c6397d3802ae5a /src/libcore | |
| parent | 4efc0a7811ee0e422dfc5d8a871b54160c18e35b (diff) | |
| download | rust-0e62990760c0cd4032463dd9024a3dbd16a8de8a.tar.gz rust-0e62990760c0cd4032463dd9024a3dbd16a8de8a.zip | |
Clarify `ManuallyDrop` docs
Mention that you can use `into_inner` to drop the contained value.
Diffstat (limited to 'src/libcore')
| -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>) { |
