Tehforsch / diman

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

Fix the way the conversion factor is obtained in serde and `Debug` impls #33

Closed Tehforsch closed 6 months ago

Tehforsch commented 9 months ago

The code is extremely ugly. Should be easy enough to generate code that matches all defined units, in code similar to the following

let conversion_factor =
if D == Dimension { length: 0, ..NONE } {
    match unit_symbol {
        "%" => 0.01,
        "dimensionless" => 1.0,
    }
}