File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -35,8 +35,15 @@ pub trait MoveMap<T> {
3535} 
3636
3737impl < T >  MoveMap < T >  for  Vec < T >  { 
38-     fn  move_map ( self ,  f:  |T | -> T )  -> Vec < T >  { 
39-         self . move_iter ( ) . map ( f) . collect ( ) 
38+     fn  move_map ( mut  self ,  f:  |T | -> T )  -> Vec < T >  { 
39+         use  std:: { mem,  ptr} ; 
40+         for  p in  self . mut_iter ( )  { 
41+             unsafe  { 
42+                 // FIXME(#5016) this shouldn't need to zero to be safe. 
43+                 mem:: move_val_init ( p,  f ( ptr:: read_and_zero ( p) ) ) ; 
44+             } 
45+         } 
46+         self 
4047    } 
4148} 
4249
Original file line number Diff line number Diff line change @@ -31,8 +31,14 @@ impl<T: 'static> P<T> {
3131        f ( * self . ptr ) 
3232    } 
3333
34-     pub  fn  map ( self ,  f:  |T | -> T )  -> P < T >  { 
35-         self . and_then ( |x| P ( f ( x) ) ) 
34+     pub  fn  map ( mut  self ,  f:  |T | -> T )  -> P < T >  { 
35+         use  std:: { mem,  ptr} ; 
36+         unsafe  { 
37+             let  p = & mut  * self . ptr ; 
38+             // FIXME(#5016) this shouldn't need to zero to be safe. 
39+             mem:: move_val_init ( p,  f ( ptr:: read_and_zero ( p) ) ) ; 
40+         } 
41+         self 
3642    } 
3743} 
3844
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments