You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am writing a function, which uses the cast between "Complex" and other "Num"s such as "u64, f64, Complex". The cast between "Complex" and primitive will be correct. But how can I easily cast between "Complex" and "Complex"? This always return a "None" and leads panic.
let a:Complex64;let b:Complex64 = Complex64{re:(1.),im:(2.)};
a = cast::<Complex64,Complex64>(b).unwrap();println!("{}", a);
The text was updated successfully, but these errors were encountered:
Hmm, NumCast won't work because it goes through ToPrimitive, so you get None when there's an imaginary part.
I think we would ideally implement something like TryFrom<Complex<U>> for Complex<T> where T: TryFrom<U>, but that will probably conflict with the reflexive case, T = U. That leaves us with manually (or by macro) expanding a bunch of combinations, which is gross, but possible. Or we could just add a direct conversion method on Complex itself.
I am writing a function, which uses the cast between "Complex" and other "Num"s such as "u64, f64, Complex". The cast between "Complex" and primitive will be correct. But how can I easily cast between "Complex" and "Complex"? This always return a "None" and leads panic.
The text was updated successfully, but these errors were encountered: