Skip to content
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

num_complex users should be allowed to write let mut x = (1.0, 2,0)_c64 #88

Closed
pwplus7 opened this issue Feb 24, 2021 · 4 comments · Fixed by #126
Closed

num_complex users should be allowed to write let mut x = (1.0, 2,0)_c64 #88

pwplus7 opened this issue Feb 24, 2021 · 4 comments · Fixed by #126

Comments

@pwplus7
Copy link

pwplus7 commented Feb 24, 2021

...

@cuviper
Copy link
Member

cuviper commented Feb 24, 2021

It sounds like you want something like C++ user-defined literals, but there's no such mechanism in Rust.

@pwplus7
Copy link
Author

pwplus7 commented Feb 25, 2021 via email

@cuviper
Copy link
Member

cuviper commented Feb 25, 2021

Rust's f64 is a primitive language-defined type, with built-in support for parsing with the _f64 suffix. Complex is an external type that the Rust compiler knows nothing about when it is parsing your code.

I mentioned C++ only for comparison, because that feature does allow C++ users to define new suffixes like _c64. Rust does not have a feature like that, so I can't define any custom suffixes for num-complex.

We could possibly create shorter constructors, c64(1.0, 2.0), as discussed in #21, but you would have to use num_complex::c64; first to import that function into scope.

@pwplus7
Copy link
Author

pwplus7 commented Feb 25, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants