diff options
Diffstat (limited to '')
-rw-r--r-- | dhall_core/src/context.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/dhall_core/src/context.rs b/dhall_core/src/context.rs index 877843d..b500226 100644 --- a/dhall_core/src/context.rs +++ b/dhall_core/src/context.rs @@ -43,6 +43,20 @@ impl<K: Hash + Eq + Clone, T> Context<K, T> { .collect(), ) } + + pub fn lookup_all<'a>(&'a self, k: &K) -> impl Iterator<Item = &T> { + self.0.get(k).into_iter().flat_map(|v| v.iter()) + } + + pub fn iter<'a>(&'a self) -> impl Iterator<Item = (&K, &T)> { + self.0 + .iter() + .flat_map(|(k, vs)| vs.iter().map(move |v| (k, v))) + } + + pub fn iter_keys<'a>(&'a self) -> impl Iterator<Item = (&K, &Vec<T>)> { + self.0.iter() + } } impl<K: Hash + Eq + Clone, T: Clone> Context<K, T> { |