Skip to main content

MapEntry

Trait MapEntry 

Source
pub trait MapEntry {
    type Key;
    type Value;

    // Required methods
    fn into_parts(self) -> (Self::Key, Self::Value);
    fn from_parts(key: Self::Key, value: Self::Value) -> Self;
}
Expand description

An entry that splits into a key and a value.

This is what lets the derive talk about the K and the V of a HashMap<K, V> when all it can name is the collection’s Item. It is implemented for (K, V), which is what every std map iterates as; implement it yourself only if you have a map whose entry type is not a tuple.

Required Associated Types§

Source

type Key

The part identifying the entry. Entries with equal keys are the same entry, and so are diffed against each other rather than swapped.

Source

type Value

The part that gets diffed.

Required Methods§

Source

fn into_parts(self) -> (Self::Key, Self::Value)

Splits the entry into its parts.

Source

fn from_parts(key: Self::Key, value: Self::Value) -> Self

Reassembles an entry from parts, so it can be put back into a collection.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<K, V> MapEntry for (K, V)

Source§

type Key = K

Source§

type Value = V

Source§

fn into_parts(self) -> (K, V)

Source§

fn from_parts(key: K, value: V) -> Self

Implementors§