2018-11-01 12:05:45 +00:00
|
|
|
#[derive(Debug)]
|
|
|
|
pub struct StaticMap<'a, K, V> {
|
|
|
|
pub entries: &'a [(K,V)],
|
|
|
|
}
|
|
|
|
|
2018-11-01 12:45:10 +00:00
|
|
|
impl<'a, K: Eq, V> StaticMap<'a, K, V> {
|
2018-11-01 12:05:45 +00:00
|
|
|
|
|
|
|
#[inline]
|
|
|
|
pub fn len(&self) -> usize {
|
|
|
|
self.entries.len()
|
|
|
|
}
|
|
|
|
|
2018-11-01 12:45:10 +00:00
|
|
|
pub fn get(&self, key: &K) -> Option<&V> {
|
2018-11-01 12:05:45 +00:00
|
|
|
for (ref k, ref v) in self.entries {
|
|
|
|
if k == key { return Some(v) }
|
|
|
|
}
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|