Skip to content

Commit

Permalink
Merge pull request #952 from Lucretiel/map-traits
Browse files Browse the repository at this point in the history
Add clone_from and use IndexMap::extend
  • Loading branch information
dtolnay committed Nov 18, 2022
2 parents ca41bdd + 3347248 commit 057957c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/map.rs
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 057957c

Please sign in to comment.