-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Make Vec* methods const #4600
Comments
This is not possible as However, there is a macro |
Very reasonable. This is fundamentally blocked on float math being usable in const functions. Once that's in, I expect |
Floats can't be const? TIL, though I guess that makes sense if a machine doesn't adhere to 754. |
Actually, are you sure? This compiles just fine for me: #[derive(Debug)]
struct Blah(f32, f32);
const BLAH: Blah = foo(1., 2.);
const fn foo(blah: f32, boo: f32) -> Blah {
Blah(blah, boo)
}
pub fn use_it() {
println!("{:?}", BLAH);
} |
Related issue: bitshifter/glam-rs#76 |
const fn add_two() -> f32 {
2. + 2.
} This should fail to compile :( Here's the Rust issue: rust-lang/rust#57241 |
Hmmm, all I'd want is |
That's ultimately a question for upstream. Maybe try it out in a |
If you just want that in a |
Good point, I guess I'll just use the macro though it seems weird to require that. |
Closing out, although once the linked |
What problem does this solve or what need does it fill?
I'd like to use Vec2 in a static declaration, but that's currently not possible.
What solution would you like?
Make Vec* methods const.
The text was updated successfully, but these errors were encountered: