refactor: rename confusing index variable
This commit is contained in:
parent
9bd0318702
commit
0ede27e927
1 changed files with 5 additions and 5 deletions
|
|
@ -91,23 +91,23 @@ fn collapse_toplevel(nodes: &mut Vec<Node>, mut end: usize) -> Result<(), Error>
|
||||||
|
|
||||||
macro_rules! collapse_operator {
|
macro_rules! collapse_operator {
|
||||||
($operator:expr) => {
|
($operator:expr) => {
|
||||||
while let Some(operator) = nodes[start..end]
|
while let Some(index) = nodes[start..end]
|
||||||
.iter()
|
.iter()
|
||||||
.position(|n| *n == Node::Operator($operator))
|
.position(|n| *n == Node::Operator($operator))
|
||||||
{
|
{
|
||||||
let lhs = match nodes.remove(start + operator - 1) {
|
let lhs = match nodes.remove(start + index - 1) {
|
||||||
Node::Number(n) => n,
|
Node::Number(n) => n,
|
||||||
n => return Err(Error::InvalidOperand(n)),
|
n => return Err(Error::InvalidOperand(n)),
|
||||||
};
|
};
|
||||||
end -= 1;
|
end -= 1;
|
||||||
match nodes.get_mut(start + operator) {
|
match nodes.get_mut(start + index) {
|
||||||
None => return Err(Error::OutOfBounds(Nodes(nodes.clone()), start + operator)),
|
None => return Err(Error::OutOfBounds(Nodes(nodes.clone()), start + index)),
|
||||||
|
|
||||||
Some(Node::Number(n)) => $operator.apply_to(n, lhs),
|
Some(Node::Number(n)) => $operator.apply_to(n, lhs),
|
||||||
Some(n) => return Err(Error::InvalidOperand(n.clone())),
|
Some(n) => return Err(Error::InvalidOperand(n.clone())),
|
||||||
};
|
};
|
||||||
|
|
||||||
nodes.remove(start + operator - 1);
|
nodes.remove(start + index - 1);
|
||||||
end -= 1;
|
end -= 1;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue