Skip to content

Commit d8afe56

Browse files
committed
add third batch of feedback from review
1 parent 8fd3010 commit d8afe56

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

library/core/src/mem/drop_guard.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use crate::fmt::{self, Debug};
22
use crate::mem::ManuallyDrop;
33
use crate::ops::{Deref, DerefMut};
4-
use crate::ptr;
54

65
/// Wrap a value and run a closure when dropped.
76
///
@@ -88,7 +87,7 @@ where
8887
// Next we manually read the stored value from the guard.
8988
//
9089
// SAFETY: this is safe because we've taken ownership of the guard.
91-
let value = unsafe { ptr::read(&*guard.inner) };
90+
let value = unsafe { ManuallyDrop::take(&mut guard.inner) };
9291

9392
// Finally we drop the stored closure. We do this *after* having read
9493
// the value, so that even if the closure's `drop` function panics,

0 commit comments

Comments
 (0)