Skip to content

Commit

Permalink
Revert trait derives; add clone_from
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucretiel committed Nov 17, 2022
1 parent 0248fbb commit 1acac29
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion src/map.rs
Expand Up @@ -23,7 +23,6 @@ use alloc::collections::{btree_map, BTreeMap};
use indexmap::{self, IndexMap};

/// Represents a JSON key/value type.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Map<K, V> {
map: MapImpl<K, V>,
}
Expand Down Expand Up @@ -297,6 +296,29 @@ impl Default for Map<String, Value> {
}
}

impl Clone for Map<String, Value> {
#[inline]
fn clone(&self) -> Self {
Map {
map: self.map.clone(),
}
}

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

impl PartialEq for Map<String, Value> {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.map.eq(&other.map)
}
}

impl Eq for Map<String, Value> {}

/// Access an element of this map. Panics if the given key is not present in the
/// map.
///
Expand Down Expand Up @@ -346,6 +368,13 @@ where
}
}

impl Debug for Map<String, Value> {
#[inline]
fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> {
self.map.fmt(formatter)
}
}

#[cfg(any(feature = "std", feature = "alloc"))]
impl serde::ser::Serialize for Map<String, Value> {
#[inline]
Expand Down

0 comments on commit 1acac29

Please sign in to comment.