Skip to content

Commit 426d5ea

Browse files
committed
Auto merge of #329 - JustForFun88:update_rustc_entry, r=Amanieu
Removing third copy operation for RustcOccupiedEntry::insert Continuation of #327.
2 parents 8d6e14d + 38c79ef commit 426d5ea

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/rustc_entry.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -431,10 +431,8 @@ impl<'a, K, V, A: Allocator + Clone> RustcOccupiedEntry<'a, K, V, A> {
431431
/// assert_eq!(map["poneyland"], 15);
432432
/// ```
433433
#[cfg_attr(feature = "inline-more", inline)]
434-
pub fn insert(&mut self, mut value: V) -> V {
435-
let old_value = self.get_mut();
436-
mem::swap(&mut value, old_value);
437-
value
434+
pub fn insert(&mut self, value: V) -> V {
435+
mem::replace(self.get_mut(), value)
438436
}
439437

440438
/// Takes the value out of the entry, and returns it.

0 commit comments

Comments
 (0)