From 3347248d82007c9f6b9f21e6eb657a37b5dea488 Mon Sep 17 00:00:00 2001 From: Nathan West Date: Thu, 17 Nov 2022 10:56:11 -0500 Subject: [PATCH] Add `clone_from` to `Map`; `Map::append` now uses `IndexMap::extend` --- src/map.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/map.rs b/src/map.rs index 87cf54566..c17920bd9 100644 --- a/src/map.rs +++ b/src/map.rs @@ -197,9 +197,8 @@ impl Map { #[inline] pub fn append(&mut self, other: &mut Self) { #[cfg(feature = "preserve_order")] - for (k, v) in mem::replace(&mut other.map, MapImpl::default()) { - self.map.insert(k, v); - } + self.map + .extend(mem::replace(&mut other.map, MapImpl::default())); #[cfg(not(feature = "preserve_order"))] self.map.append(&mut other.map); } @@ -304,6 +303,11 @@ impl Clone for Map { map: self.map.clone(), } } + + #[inline] + fn clone_from(&mut self, source: &Self) { + self.map.clone_from(&source.map) + } } impl PartialEq for Map {