use a box for hashmap
This commit is contained in:
@@ -76,7 +76,7 @@ impl<I: Iterator<Item = Result<ParseTree, ParseError>>> Executor<I> {
|
|||||||
fn exec(
|
fn exec(
|
||||||
&mut self,
|
&mut self,
|
||||||
tree: Box<ParseTree>,
|
tree: Box<ParseTree>,
|
||||||
locals: &mut Cow<HashMap<String, Object>>) -> Result<Value, RuntimeError>
|
locals: &mut Cow<Box<HashMap<String, Object>>>) -> Result<Value, RuntimeError>
|
||||||
{
|
{
|
||||||
match *tree {
|
match *tree {
|
||||||
ParseTree::Add(x, y) => match (self.exec(x, locals)?, self.exec(y, locals)?) {
|
ParseTree::Add(x, y) => match (self.exec(x, locals)?, self.exec(y, locals)?) {
|
||||||
@@ -304,7 +304,7 @@ impl<I: Iterator<Item = Result<ParseTree, ParseError>>> Iterator for Executor<I>
|
|||||||
let expr = self.exprs.next();
|
let expr = self.exprs.next();
|
||||||
|
|
||||||
match expr {
|
match expr {
|
||||||
Some(Ok(expr)) => Some(self.exec(Box::new(expr), &mut Cow::Borrowed(&HashMap::new()))),
|
Some(Ok(expr)) => Some(self.exec(Box::new(expr), &mut Cow::Borrowed(&Box::new(HashMap::new())))),
|
||||||
Some(Err(e)) => Some(Err(RuntimeError::ParseError(e))),
|
Some(Err(e)) => Some(Err(RuntimeError::ParseError(e))),
|
||||||
None => None,
|
None => None,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user