refactor: rename confusing index variable

This commit is contained in:
electria 2026-10-20 19:26:14 -07:00
commit 0ede27e927
Signed by: electria
SSH key fingerprint: SHA256:8LlB3ucPbBHqozqkhsNbaV5oG3SlzzqUj8FZDL6IPQs

View file

@ -91,23 +91,23 @@ fn collapse_toplevel(nodes: &mut Vec<Node>, mut end: usize) -> Result<(), Error>
macro_rules! collapse_operator {
($operator:expr) => {
while let Some(operator) = nodes[start..end]
while let Some(index) = nodes[start..end]
.iter()
.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,
n => return Err(Error::InvalidOperand(n)),
};
end -= 1;
match nodes.get_mut(start + operator) {
None => return Err(Error::OutOfBounds(Nodes(nodes.clone()), start + operator)),
match nodes.get_mut(start + index) {
None => return Err(Error::OutOfBounds(Nodes(nodes.clone()), start + index)),
Some(Node::Number(n)) => $operator.apply_to(n, lhs),
Some(n) => return Err(Error::InvalidOperand(n.clone())),
};
nodes.remove(start + operator - 1);
nodes.remove(start + index - 1);
end -= 1;
}
};