File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed
Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ use core::ptr;
1010const DATA_WORDS : usize = 3 ;
1111
1212/// Some space to keep a `FnOnce()` object on the stack.
13- type Data = [ usize ; DATA_WORDS ] ;
13+ type Data = MaybeUninit < [ usize ; DATA_WORDS ] > ;
1414
1515/// A `FnOnce()` that is stored inline if small, or otherwise boxed on the heap.
1616///
@@ -50,22 +50,22 @@ impl Deferred {
5050 if size <= mem:: size_of :: < Data > ( )
5151 && align <= mem:: align_of :: < Data > ( )
5252 {
53- let mut data = MaybeUninit :: < Data > :: uninit ( ) ;
53+ let mut data = Data :: uninit ( ) ;
5454 ptr:: write ( data. as_mut_ptr ( ) as * mut F , f) ;
5555
5656 Deferred {
5757 call : call_raw :: < F > ,
58- data : data . assume_init ( ) ,
58+ data,
5959 _marker : PhantomData ,
6060 }
6161 } else {
6262 let b: Box < F > = Box :: new ( f) ;
63- let mut data = MaybeUninit :: < Data > :: uninit ( ) ;
63+ let mut data = Data :: uninit ( ) ;
6464 ptr:: write ( data. as_mut_ptr ( ) as * mut Box < F > , b) ;
6565
6666 Deferred {
6767 call : call_raw_box :: < F > ,
68- data : data . assume_init ( ) ,
68+ data,
6969 _marker : PhantomData ,
7070 }
7171 }
@@ -78,7 +78,7 @@ impl Deferred {
7878 let call = self . call ;
7979 #[ allow( trivial_casts) ]
8080 unsafe {
81- call ( & mut self . data as * mut Data as * mut u8 )
81+ call ( self . data . as_mut_ptr ( ) . cast ( ) )
8282 } ;
8383 }
8484}
You can’t perform that action at this time.
0 commit comments