lookup_binding only needs &str

This commit is contained in:
greg 2017-01-03 02:41:22 -08:00
parent 06771979df
commit 2996198eff

View File

@ -37,8 +37,8 @@ impl<'a> Evaluator<'a> {
self.variables.insert(var, value); self.variables.insert(var, value);
} }
fn lookup_binding(&self, var: String) -> Option<Expression> { fn lookup_binding(&self, var: &str) -> Option<Expression> {
match self.variables.get(&var) { match self.variables.get(var) {
Some(expr) => Some(expr.clone()), Some(expr) => Some(expr.clone()),
None => match self.parent { None => match self.parent {
Some(env) => env.lookup_binding(var), Some(env) => env.lookup_binding(var),
@ -158,7 +158,7 @@ impl<'a> Evaluator<'a> {
e @ StringLiteral(_) => (e, None), e @ StringLiteral(_) => (e, None),
e @ Number(_) => (e, None), e @ Number(_) => (e, None),
e @ Lambda(_) => (e, None), e @ Lambda(_) => (e, None),
Variable(var) => { Variable(ref var) => {
match self.lookup_binding(var) { match self.lookup_binding(var) {
None => (Null, None), None => (Null, None),
Some(expr) => (expr, None), Some(expr) => (expr, None),