@@ -3587,10 +3587,8 @@ impl<'a, K, V, S, A: Allocator + Clone> OccupiedEntry<'a, K, V, S, A> {
3587
3587
/// assert_eq!(map["poneyland"], 15);
3588
3588
/// ```
3589
3589
#[ 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)
3594
3592
}
3595
3593
3596
3594
/// 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,
4256
4254
/// assert_eq!(map["poneyland"], 15);
4257
4255
/// ```
4258
4256
#[ 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)
4263
4259
}
4264
4260
4265
4261
/// Takes the value out of the entry, and returns it.
0 commit comments