-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proposal: Complex helper constructors #78
Comments
You can already use I wouldn't use |
The only reason I suggested the Regarding the |
The problem with brevity is that it also tends toward ambiguity. I'd rather keep clear, idiomatic methods in the official API, but of course you could write your own brief helpers locally. |
Another reason for wanting these constructors, is because they could be made And I agree, ambiguity should be avoided. |
That would be nice, but we can't call |
right, that's necessary due to the generic nature of the Complex structs |
I have a simple request based on an actual use-case that I needed: helper functions to create reals and imaginaries directly.
With these two constructors we'd be able to simply write
Complex::im(2.0)
instead ofComplex::new(0.0, 2.0)
, which would make it slightly more ergonomic for the cases where you know for a fact you don't need one of the parts right away, but do need a Complex number.Similarly (or alternatively) a set of conversion functions from a scalar
Num
to a complex one would be nice too, so we can write2.0.to_im()
to achieve the same or a similar result.The text was updated successfully, but these errors were encountered: