Closed stijnfrishert closed 4 years ago
History. The Float
trait existed before FloatConst
, and it would be a breaking change to add new constraints now.
We could do that with a bump to the semantic version, but I've been loath to consider that since these traits are often in the public API of other crates. That would make it a breaking change for those crates to adopt new num-traits
, so the ecosystem upgrade would be painful.
Ah sure, I get that. Too bad the ecosystem has developed in such a way that it makes it hard for popular crates like these to upgrade.
In any case, I guess this can be closed. Thanks for explaining.
FWIW, it should be easy to define your own combined trait for convenience, like:
use num_traits::{Float, FloatConst};
trait MyFloat: Float + FloatConst {}
impl<T: Float + FloatConst> MyFloat for T {}
Yeah, that might be a good idea if my codebase grows larger. For now just playing around, but thank you for the tip!
Makes sense to me that every Float should be able to provide values such as π by default.
(Once again, pretty new to Rust, so if this doesn't make any sense I'd love to learn why not too)