Add support for some serde serialization (#847)

* Add support for some serde serialization
This commit is contained in:
Artur Jamro
2019-07-12 15:30:50 -07:00
committed by Dan Gohman
parent 8edc40cb49
commit 9e884b4433
8 changed files with 33 additions and 0 deletions

View File

@@ -56,11 +56,23 @@ where
}
}
/// Returns the number of elements in the underlying vector.
///
/// The number is not necessarily the same as the length of the corresponding PrimaryMap.
pub fn len(&self) -> usize {
self.elems.len()
}
/// Get the element at `k` if it exists.
pub fn get(&self, k: K) -> Option<&V> {
self.elems.get(k.index())
}
/// Get the default value.
pub fn get_default(&self) -> &V {
&self.default
}
/// Is this map completely empty?
pub fn is_empty(&self) -> bool {
self.elems.is_empty()