Replacement trait for std::num::Float?


#1

With the beta release std::num::Float has been deprecated. Does this mean that the trait is gone or was it simply moved?

I ask because I’m using it for my quaternion and vector classes, which is generic over f32 and f64 and make extensive use of the Float trait.


#2

The rust devs want to wait a bit before stabilizing number traits (I believe they are waiting for HKT). In the mean-time you can use the num crate on crates.io.


#3

A lot of the Float functionality moved directly to the primitives f32 and f64 recently. You can’t find them because rustdoc search has an annoying bug making it miss these.

These require specifically annotating the type: 1.0f32.exp() works but 1.0.exp() doesn’t.


#4

Thanks. The num crate is exactly what I’m looking for. What is HKT?


#5

HKT = higher-kinded types


#6

Actually, they are waiting mainly for associated constants.