Tehforsch / diman

Define rust compile time unit systems using const generics
52 stars 2 forks source link

impl `num_traits` for `Quantity`. #69

Open Tehforsch opened 8 months ago

Tehforsch commented 8 months ago

As discussed in #55 Quantity should probably implement at least some of the num_traits. In the current implementation, the methods are just anonymous methods that happen to be named the exact same way as the corresponding methods on some of the num traits.

For dimensionless quantities, virtually any traits that f32 fulfills should be possible on Quantity<f32, Dimension::none()> as well. Mainly I am thinking of

The following would be possible on all quantities:

There are a few more and we'd have to look at what we need. For now, I'd probably start by moving the methods that were changed in #55 into the Float trait. Curiously, this trait isn't necessarily unit safe though, because of #57. I suppose we could overlook this for now, but I am not super happy about that.