File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -1449,6 +1449,25 @@ pub trait InPlaceWrite<T> {
14491449 fn write_pin_init < E > ( self , init : impl PinInit < T , E > ) -> Result < Pin < Self :: Initialized > , E > ;
14501450}
14511451
1452+ impl < ' a , T > InPlaceWrite < T > for & ' static mut MaybeUninit < T > {
1453+ type Initialized = & ' static mut T ;
1454+ fn write_init < E > ( self , init : impl Init < T , E > ) -> Result < Self :: Initialized , E > {
1455+ let slot = self . as_mut_ptr ( ) ;
1456+ // SAFETY: `self` is a valid pointer to uninitialized memory.
1457+ unsafe { init. __init ( slot) ? } ;
1458+ // SAFETY: The above call initialized the memory.
1459+ Ok ( unsafe { & mut * slot } )
1460+ }
1461+
1462+ fn write_pin_init < E > ( self , init : impl PinInit < T , E > ) -> Result < Pin < Self :: Initialized > , E > {
1463+ let slot = self . as_mut_ptr ( ) ;
1464+ // SAFETY: `self` is a valid pointer to uninitialized memory.
1465+ unsafe { init. __pinned_init ( slot) ? } ;
1466+ // SAFETY: The above call initialized the memory.
1467+ Ok ( unsafe { Pin :: new_unchecked ( & mut * slot) } )
1468+ }
1469+ }
1470+
14521471/// Trait facilitating pinned destruction.
14531472///
14541473/// Use [`pinned_drop`] to implement this trait safely:
You can’t perform that action at this time.
0 commit comments