Closed Boscop closed 2 years ago
Once const fn
is stabilized, I definitely think all of the constructors should be! Right now there's some pretty heated debate currently still happening on the stabilization tracking issue. I'd rather wait for stabilization, but if needed sooner, I can certainly add another nightly-only feature flag in the interim.
Hi there, now that const fn
is stable, are there any plans to make from_f32
a const fn? Thanks!
If I remember correctly, it's just waiting on https://github.com/rust-lang/rust/issues/57241 to make f32/f64::from/to_bits const, but there's unresolved issues to be addressed there
With the release of Rust 1.56, mem::transmute
was const
stabilized. This allowed me to implement const
conversions as new functions (from_f32_const
instead of just from_f32
). This allows existing from_f32
functions to continue using hardware intrinsics when available.
I'll be holding off on publishing a new version until the above linked issue is const
stabilized so that to_bits
/from_bits
can be used again and avoid those unsafe mem::transmute
calls. If anyone wants access sooner without using a git dependency, just say so and I'll publish a pre-release.
It looks like to_bits
/from_bits
will take a lot longer to stabilize due to general float soudness concerns. Went ahead and released current const
conversions as-is with mem::transmute
implementation for now.
Could
from_f32()
etc. be const-fn? Would be useful for halving the size of float data in static arrays in demoscene intros.