File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -397,13 +397,23 @@ impl<'a, T: ?Sized> From<&'a mut T> for PtrMut<'a> {
397397} 
398398
399399impl < ' a >  OwningPtr < ' a >  { 
400+     /// This exists mostly to reduce compile times; 
401+ /// code is only duplicated per type, rather than per function called. 
402+ /// 
403+ /// # Safety 
404+ /// 
405+ /// Safety constraints of [`PtrMut::promote`] must be upheld. 
406+ unsafe  fn  make_internal < T > ( temp :  & mut  ManuallyDrop < T > )  -> OwningPtr < ' _ >  { 
407+         // SAFETY: The constraints of `promote` are upheld by caller. 
408+         unsafe  {  PtrMut :: from ( & mut  * temp) . promote ( )  } 
409+     } 
410+ 
400411    /// Consumes a value and creates an [`OwningPtr`] to it while ensuring a double drop does not happen. 
401412#[ inline]  
402413    pub  fn  make < T ,  F :  FnOnce ( OwningPtr < ' _ > )  -> R ,  R > ( val :  T ,  f :  F )  -> R  { 
403-         let  mut  temp = ManuallyDrop :: new ( val) ; 
404414        // SAFETY: The value behind the pointer will not get dropped or observed later, 
405415        // so it's safe to promote it to an owning pointer. 
406-         f ( unsafe  {  PtrMut :: from ( & mut  * temp ) . promote ( )  } ) 
416+         f ( unsafe  {  Self :: make_internal ( & mut  ManuallyDrop :: new ( val ) )  } ) 
407417    } 
408418} 
409419
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments