We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8fd3010 commit d8afe56Copy full SHA for d8afe56
library/core/src/mem/drop_guard.rs
@@ -1,7 +1,6 @@
1
use crate::fmt::{self, Debug};
2
use crate::mem::ManuallyDrop;
3
use crate::ops::{Deref, DerefMut};
4
-use crate::ptr;
5
6
/// Wrap a value and run a closure when dropped.
7
///
@@ -88,7 +87,7 @@ where
88
87
// Next we manually read the stored value from the guard.
89
//
90
// SAFETY: this is safe because we've taken ownership of the guard.
91
- let value = unsafe { ptr::read(&*guard.inner) };
+ let value = unsafe { ManuallyDrop::take(&mut guard.inner) };
92
93
// Finally we drop the stored closure. We do this *after* having read
94
// the value, so that even if the closure's `drop` function panics,
0 commit comments