@@ -3587,10 +3587,8 @@ impl<'a, K, V, S, A: Allocator + Clone> OccupiedEntry<'a, K, V, S, A> {
35873587 /// assert_eq!(map["poneyland"], 15);
35883588 /// ```
35893589 #[ cfg_attr( feature = "inline-more" , inline) ]
3590- pub fn insert ( & mut self , mut value : V ) -> V {
3591- let old_value = self . get_mut ( ) ;
3592- mem:: swap ( & mut value, old_value) ;
3593- value
3590+ pub fn insert ( & mut self , value : V ) -> V {
3591+ mem:: replace ( self . get_mut ( ) , value)
35943592 }
35953593
35963594 /// Takes the value out of the entry, and returns it.
@@ -4256,10 +4254,8 @@ impl<'a, 'b, K, Q: ?Sized, V, S, A: Allocator + Clone> OccupiedEntryRef<'a, 'b,
42564254 /// assert_eq!(map["poneyland"], 15);
42574255 /// ```
42584256 #[ cfg_attr( feature = "inline-more" , inline) ]
4259- pub fn insert ( & mut self , mut value : V ) -> V {
4260- let old_value = self . get_mut ( ) ;
4261- mem:: swap ( & mut value, old_value) ;
4262- value
4257+ pub fn insert ( & mut self , value : V ) -> V {
4258+ mem:: replace ( self . get_mut ( ) , value)
42634259 }
42644260
42654261 /// Takes the value out of the entry, and returns it.
0 commit comments