diff options
| author | Nathan Reiner <nathan@nathanreiner.xyz> | 2024-01-17 22:30:02 +0100 |
|---|---|---|
| committer | Nathan Reiner <nathan@nathanreiner.xyz> | 2024-01-17 22:30:02 +0100 |
| commit | 77cf9aa7535a1d9481f0bd3caeea26e2b85c5019 (patch) | |
| tree | 03b794cc47e14da1d3896c4251c89fa6c40a7132 /src/operation.rs | |
| parent | 5ccc6e5ec8a433f68bfeb17e8dcedec5b62a36a9 (diff) | |
migrate from f64 to own complex
Diffstat (limited to 'src/operation.rs')
| -rw-r--r-- | src/operation.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/operation.rs b/src/operation.rs index 861fb5a..1ee3d5c 100644 --- a/src/operation.rs +++ b/src/operation.rs @@ -1,5 +1,6 @@ +use crate::complex::Complex; -pub type Operator = dyn Fn(f64, f64) -> f64; +pub type Operator = dyn Fn(Complex, Complex) -> Complex; pub struct Operation { sign: char, @@ -15,14 +16,14 @@ impl Operation { self.sign } - pub fn evaluate(&self, a: f64, b: f64) -> f64 { + pub fn evaluate(&self, a: Complex, b: Complex) -> Complex { (self.func)(a, b) } } #[macro_export] -macro_rules! opvec { - ($(($x:expr, $y:expr)), *) => { +macro_rules! operations { + ({$($x:expr => $y:expr), *}) => { vec![$( Operation::new($x, Box::new($y)), )*] |