Tehforsch / diman

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

`round` should not exist on floats #57

Open Tehforsch opened 9 months ago

Tehforsch commented 9 months ago

round is not a unit-safe method since it depends on the underlying base unit in the current implementation. I don't think it should exist on quantities right now.

Doing this properly would require either generating methods of the form round_in_<unit>, or could be done cleaner using the proposal in #56 by adding a round_in method which takes a unit ZST as an argument:

let length = Meters(1.95);
let feet = length.round_in(Feet);
let inches = (length - Feet(feet)).round_in(Inches);