Tehforsch / diman

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

Better unit selection in `Debug` impl #67

Open Tehforsch opened 8 months ago

Tehforsch commented 8 months ago

Ever since #44, the old behavior of selecting a nice unit to display the quantity in was disabled since there were just too many units to make sense of the result. (10m would be printed as 1 dam).

There are many solutions to this, but I think a nice one should prevent certain prefixes from ever being printed in (deca, hecto) - if one really wants to go overboard this could be unit specific (hPa is used) and we could add an attribute #[debug_print] over a unit to declare a preferred unit for printing in (#41 ).

The main difficulty in implementing any of this (this applies to #33 ) is that storing the unit information at runtime is very awkward currently. What I'd like to do is define a proper container for the runtime information we have about units that can quickly answer questions such as "what are all the units for a given dimension".