pub struct MapFirstKeyWins<K, V>(/* private fields */);
Expand description
Ensure that the last value is taken, if duplicate values exist
By default serde has a first-value-wins implementation, if duplicate keys for a set exist. Sometimes the opposite strategy is desired. This helper implements a first-value-wins strategy.
The implementation supports both the HashSet
and the BTreeSet
from the standard library.
Trait Implementations§
Source§impl<'de, K, V, KAs, VAs> DeserializeAs<'de, BTreeMap<K, V>> for MapFirstKeyWins<KAs, VAs>
impl<'de, K, V, KAs, VAs> DeserializeAs<'de, BTreeMap<K, V>> for MapFirstKeyWins<KAs, VAs>
Source§fn deserialize_as<D>(deserializer: D) -> Result<BTreeMap<K, V>, D::Error>where
D: Deserializer<'de>,
fn deserialize_as<D>(deserializer: D) -> Result<BTreeMap<K, V>, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer.
Source§impl<'de, K, V, KAs, VAs, S> DeserializeAs<'de, HashMap<K, V, S>> for MapFirstKeyWins<KAs, VAs>where
KAs: DeserializeAs<'de, K>,
VAs: DeserializeAs<'de, V>,
K: Eq + Hash,
S: BuildHasher + Default,
impl<'de, K, V, KAs, VAs, S> DeserializeAs<'de, HashMap<K, V, S>> for MapFirstKeyWins<KAs, VAs>where
KAs: DeserializeAs<'de, K>,
VAs: DeserializeAs<'de, V>,
K: Eq + Hash,
S: BuildHasher + Default,
Source§fn deserialize_as<D>(deserializer: D) -> Result<HashMap<K, V, S>, D::Error>where
D: Deserializer<'de>,
fn deserialize_as<D>(deserializer: D) -> Result<HashMap<K, V, S>, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer.
Source§impl<K, KAs, V, VAs> SerializeAs<BTreeMap<K, V>> for MapFirstKeyWins<KAs, VAs>where
KAs: SerializeAs<K>,
VAs: SerializeAs<V>,
impl<K, KAs, V, VAs> SerializeAs<BTreeMap<K, V>> for MapFirstKeyWins<KAs, VAs>where
KAs: SerializeAs<K>,
VAs: SerializeAs<V>,
Source§fn serialize_as<S>(
value: &BTreeMap<K, V>,
serializer: S,
) -> Result<S::Ok, S::Error>where
S: Serializer,
fn serialize_as<S>(
value: &BTreeMap<K, V>,
serializer: S,
) -> Result<S::Ok, S::Error>where
S: Serializer,
Serialize this value into the given Serde serializer.
Source§impl<K, KAs, V, VAs, H> SerializeAs<HashMap<K, V, H>> for MapFirstKeyWins<KAs, VAs>
impl<K, KAs, V, VAs, H> SerializeAs<HashMap<K, V, H>> for MapFirstKeyWins<KAs, VAs>
Source§fn serialize_as<S>(
value: &HashMap<K, V, H>,
serializer: S,
) -> Result<S::Ok, S::Error>where
S: Serializer,
fn serialize_as<S>(
value: &HashMap<K, V, H>,
serializer: S,
) -> Result<S::Ok, S::Error>where
S: Serializer,
Serialize this value into the given Serde serializer.
Auto Trait Implementations§
impl<K, V> Freeze for MapFirstKeyWins<K, V>
impl<K, V> RefUnwindSafe for MapFirstKeyWins<K, V>where
K: RefUnwindSafe,
V: RefUnwindSafe,
impl<K, V> Send for MapFirstKeyWins<K, V>
impl<K, V> Sync for MapFirstKeyWins<K, V>
impl<K, V> Unpin for MapFirstKeyWins<K, V>
impl<K, V> UnwindSafe for MapFirstKeyWins<K, V>where
K: UnwindSafe,
V: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more