summaryrefslogtreecommitdiff
path: root/src/model/scope.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/model/scope.rs')
-rw-r--r--src/model/scope.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/model/scope.rs b/src/model/scope.rs
index bb0d4684..40307cba 100644
--- a/src/model/scope.rs
+++ b/src/model/scope.rs
@@ -108,6 +108,15 @@ impl Scope {
self.0.insert(var.into(), Slot::new(value.into(), Kind::Captured));
}
+ /// Copy definitions from another scope that aren't yet defined in this one.
+ pub fn copy_from(&mut self, other: &Self) {
+ for (name, value) in other.iter() {
+ self.0
+ .entry(name.clone())
+ .or_insert_with(|| Slot::new(value.clone(), Kind::Normal));
+ }
+ }
+
/// Try to access a variable immutably.
pub fn get(&self, var: &str) -> Option<&Value> {
self.0.get(var).map(Slot::read)