use crate::complex::Complex; pub type Operator = fn(Complex, Complex) -> Complex; #[derive(Clone)] pub struct Operation { sign: char, func: Operator } impl Operation { pub fn new(sign: char, func: Operator) -> Self { Self { sign, func } } pub fn sign(&self) -> char { self.sign } pub fn evaluate(&self, a: Complex, b: Complex) -> Complex { (self.func)(a, b) } } #[macro_export] macro_rules! operations { {$($x:expr => $y:expr), *} => { vec![$( Operation::new($x, Box::new($y)), )*] }; }