pub trait KeyValue<'a> {
type K: Ord;
type V;
// Required methods
fn key(&'a self) -> Self::K;
fn value(&'a self) -> Self::V;
}Expand description
Trait that T must implement to be able to work with MapOfIndexes of T.
Can be implemented on your own custom structs. KeyValue::K represents the key (index) of the pair, while KeyValue::V is the value.
KeyValue is already implemented for all 2-tuples, the first element being considered as the key.
§Examples
use map_of_indexes::KeyValue;
let tuple: (String, i64) = ("Key".to_string(), 123);
// In this blanket implementation, both functions return a reference
assert_eq!(tuple.key(), &"Key");
assert_eq!(tuple.value(), &123i64);If you need a very compact representation, see CombinedKeyValue, which stores both the key and the key on a uint of a given size.