proxmox-backup/src/static_map.rs

20 lines
372 B
Rust
Raw Normal View History

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
}
}