File tree Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Original file line number Diff line number Diff line change 11// Extracted from the scopeguard crate
22use core:: {
3- mem:: ManuallyDrop ,
3+ mem,
44 ops:: { Deref , DerefMut } ,
55 ptr,
66} ;
@@ -28,16 +28,15 @@ where
2828 #[ inline]
2929 pub fn into_inner ( guard : Self ) -> T {
3030 // Cannot move out of Drop-implementing types, so
31- // ptr::read the value out of a ManuallyDrop<Self>
32- // Don't use mem::forget as that might invalidate value
33- let guard = ManuallyDrop :: new ( guard) ;
31+ // ptr::read the value and forget the guard.
3432 unsafe {
3533 let value = ptr:: read ( & guard. value ) ;
3634 // read the closure so that it is dropped, and assign it to a local
3735 // variable to ensure that it is only dropped after the guard has
3836 // been forgotten. (In case the Drop impl of the closure, or that
3937 // of any consumed captured variable, panics).
4038 let _dropfn = ptr:: read ( & guard. dropfn ) ;
39+ mem:: forget ( guard) ;
4140 value
4241 }
4342 }
You can’t perform that action at this time.
0 commit comments