Expose AllocIds for priroda

This commit is contained in:
Oliver Scherer 2019-01-22 16:46:05 +01:00
parent 1cd85d2a27
commit 7269a884c9

View File

@ -18,8 +18,11 @@ use crate::AllocMap;
pub struct MonoHashMap<K: Hash + Eq, V>(RefCell<FxHashMap<K, Box<V>>>);
impl<K: Hash + Eq, V> MonoHashMap<K, V> {
pub fn values<T>(&self, f: impl FnOnce(&mut dyn Iterator<Item=&V>) -> T) -> T {
f(&mut self.0.borrow().values().map(|v| &**v))
/// This function exists for priroda to be able to iterate over all evaluator memory
///
/// The memory of constants does not show up in this list.
pub fn iter<T>(&self, f: impl FnOnce(&mut dyn Iterator<Item=(&K, &V)>) -> T) -> T {
f(&mut self.0.borrow().iter().map(|(k, v)| (k, &**v)))
}
}