Skip to content

Commit

Permalink
Add clone_from to Map; Map::append now uses IndexMap::extend
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucretiel committed Nov 17, 2022
1 parent ca41bdd commit 3347248
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,8 @@ impl Map<String, Value> {
#[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);
}
Expand Down Expand Up @@ -304,6 +303,11 @@ impl Clone for Map<String, Value> {
map: self.map.clone(),
}
}

#[inline]
fn clone_from(&mut self, source: &Self) {
self.map.clone_from(&source.map)
}
}

impl PartialEq for Map<String, Value> {
Expand Down

0 comments on commit 3347248

Please sign in to comment.