File tree 1 file changed +3
-4
lines changed
1 file changed +3
-4
lines changed Original file line number Diff line number Diff line change 1
1
// Extracted from the scopeguard crate
2
2
use core:: {
3
- mem:: ManuallyDrop ,
3
+ mem,
4
4
ops:: { Deref , DerefMut } ,
5
5
ptr,
6
6
} ;
@@ -28,16 +28,15 @@ where
28
28
#[ inline]
29
29
pub fn into_inner ( guard : Self ) -> T {
30
30
// 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.
34
32
unsafe {
35
33
let value = ptr:: read ( & guard. value ) ;
36
34
// read the closure so that it is dropped, and assign it to a local
37
35
// variable to ensure that it is only dropped after the guard has
38
36
// been forgotten. (In case the Drop impl of the closure, or that
39
37
// of any consumed captured variable, panics).
40
38
let _dropfn = ptr:: read ( & guard. dropfn ) ;
39
+ mem:: forget ( guard) ;
41
40
value
42
41
}
43
42
}
You can’t perform that action at this time.
0 commit comments