use crate::complex::Complex; pub type Operator = dyn Fn(Complex, Complex) -> Complex; pub struct Operation { sign: char, func: Box } impl Operation { pub fn new(sign: char, func: Box) -> 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)), )*] }; }