-
-
Notifications
You must be signed in to change notification settings - Fork 484
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
const fn
constructors
#521
Comments
I don't believe this is possible quite yet! The current level of |
Aw, you're right :( I guess this becomes the tracking issue then. In the meantime I just learned about the union transmute hack, so that's the alternative for now. related rust-lang/rust#24111 |
Revisiting this issue to see if the situation improved since last year. It appears that
|
Side note, it would be nice if we could have a feature to enable these on nightly even though it'd be a mega pain to get working with macros. |
I'm pretty sure trait bounds on Edit: confirmed stable since 1.61.0, just about two years ago. |
Calling trait methods in |
The The |
Ah, in that case this is not supported yet. Indeed, you still cannot call trait methods in const (coming soon, hopefully). |
const fn
has landed in Rust stable! It would be really helpful in one of my projects if nalgebra adopted it for constructors. The shortlist of types I need isPoint2
,Point3
,Vector2
,Vector3
,UnitComplex
,UnitQuaternion
. But it probably makes sense for every type in the library.Things like
UnitComplex::new
might not work due to compile-time restrictions on FP math, but I'm happy to work around that withUnitComplex::from_cos_sin_unchecked
or whatever else makes sense.Adding the keyword is a simple enough change (at least I hope!), but it will break on older compilers and I don't know your policy on Rust version compatibility.
The text was updated successfully, but these errors were encountered: