1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
//! Traits for getting values from keys. use iter_trait::HasMapData; /// A trait for getting data out of a map. pub trait Get: HasMapData { /// Gets the value at the given key. fn get(&self, key: &Self::Key) -> Option<&Self::Value>; /// Checks whether the map contains the given key. fn contains_key(&self, key: &Self::Key) -> bool { self.get(key).is_some() } } /// A trait for getting mutable references to data in a map. pub trait GetMut: Get { /// Gets a reference to the value at the given key. fn get_mut(&mut self, key: &Self::Key) -> Option<&mut Self::Value>; }