aboutsummaryrefslogtreecommitdiff
path: root/rust/src/env.rs
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2014-10-25 16:28:32 -0500
committerJoel Martin <github@martintribe.org>2015-01-06 21:58:58 -0600
commit85bec8a08b76b5b4797ddd9976a138b22974e1c4 (patch)
tree7316f0b7442fbe45a38c39fd32ff562efb95904d /rust/src/env.rs
parent2ee5367b95e98252e1446a1cc1a782c516f21e72 (diff)
downloadmal-85bec8a08b76b5b4797ddd9976a138b22974e1c4.tar.gz
mal-85bec8a08b76b5b4797ddd9976a138b22974e1c4.zip
rust: add step6_file
Diffstat (limited to 'rust/src/env.rs')
-rw-r--r--rust/src/env.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/rust/src/env.rs b/rust/src/env.rs
index 1471d20..3c98015 100644
--- a/rust/src/env.rs
+++ b/rust/src/env.rs
@@ -73,6 +73,14 @@ pub fn env_find(env: Env, key: String) -> Option<Env> {
}
#[allow(dead_code)]
+pub fn env_root(env: &Env) -> Env {
+ match env.borrow().outer {
+ Some(ref ei) => env_root(ei),
+ None => env.clone(),
+ }
+}
+
+#[allow(dead_code)]
pub fn env_set(env: &Env, key: String, val: MalVal) {
env.borrow_mut().data.insert(key, val.clone());
}
@@ -86,7 +94,7 @@ pub fn env_get(env: Env, key: String) -> MalRet {
None => Ok(Rc::new(Nil)),
}
},
- None => Ok(Rc::new(Nil)),
+ None => Err("'".to_string() + key + "' not found".to_string()),
}
}