I have two functions:
fn f1(k1: f64, k2: f64, k3: f64) -> (f64, f64) {
let a = k1 + k2;
let b = k2 * k3.sqrt();
(a + b, a - b)
}
type Z64 = num::complex::Complex<f64>;
fn f2(k1: Z64, k2: Z64, k3: Z64) -> (Z64, Z64) {
let a = k1 + k2;
let b = k2 * k3.sqrt();
(a + b, a - b)
}
The code is identical, only the types are different. One is f64
. The other is Complex<f64>
. Is it possible to have a single function polymorphic on both types?