refactor: make Operator/Function ordering consistent

This commit is contained in:
electria 2026-10-20 18:00:08 -07:00
commit 9bd0318702
Signed by: electria
SSH key fingerprint: SHA256:8LlB3ucPbBHqozqkhsNbaV5oG3SlzzqUj8FZDL6IPQs

View file

@ -127,6 +127,17 @@ fn collapse_toplevel(nodes: &mut Vec<Node>, mut end: usize) -> Result<(), Error>
Ok(()) Ok(())
} }
impl Operator {
fn apply_to(&self, rhs: &mut Float, lhs: Float) {
match self {
Self::Plus => Float::add_from(rhs, lhs),
Self::Minus => Float::sub_from(rhs, lhs),
Self::Mult => Float::mul_from(rhs, lhs),
Self::Div => Float::div_from(rhs, lhs),
Self::Exp => Float::pow_from(rhs, lhs),
}
}
}
impl Function { impl Function {
fn apply_to(&self, n: &mut Float) { fn apply_to(&self, n: &mut Float) {
match self { match self {
@ -145,17 +156,6 @@ impl Function {
} }
} }
} }
impl Operator {
fn apply_to(&self, rhs: &mut Float, lhs: Float) {
match self {
Self::Plus => Float::add_from(rhs, lhs),
Self::Minus => Float::sub_from(rhs, lhs),
Self::Mult => Float::mul_from(rhs, lhs),
Self::Div => Float::div_from(rhs, lhs),
Self::Exp => Float::pow_from(rhs, lhs),
}
}
}
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {