Improve for loop implementation
This commit is contained in:
parent
173e7a2ee8
commit
3bb825fa58
@ -1,3 +1,6 @@
|
|||||||
|
i = 0
|
||||||
for i in [1 2 3] {
|
for i in [1 2 3] {
|
||||||
|
i += 1
|
||||||
(output i)
|
(output i)
|
||||||
}
|
}
|
||||||
|
(output i)
|
||||||
|
@ -31,15 +31,14 @@ impl AbstractTree for For {
|
|||||||
let value = self.expression.run(source, context)?;
|
let value = self.expression.run(source, context)?;
|
||||||
let list = value.as_list()?;
|
let list = value.as_list()?;
|
||||||
let key = self.identifier.inner();
|
let key = self.identifier.inner();
|
||||||
|
let mut context = context.clone();
|
||||||
|
|
||||||
for value in list {
|
for value in list {
|
||||||
context.set_value(key.clone(), value.clone())?;
|
context.set_value(key.clone(), value.clone())?;
|
||||||
|
|
||||||
self.item.run(source, context)?;
|
self.item.run(source, &mut context)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
context.set_value(key.clone(), Value::Empty)?;
|
|
||||||
|
|
||||||
Ok(Value::Empty)
|
Ok(Value::Empty)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user