uom icon indicating copy to clipboard operation
uom copied to clipboard

Types for new combined quantities are really difficult to write

Open nakedible opened this issue 4 years ago • 1 comments

I had to store the molar gas constant in a place where I had to write the type of the variable for Rust. The SI unit is "joule per kelvin per mole". Heat capacity is "joule per kelvin" and molar energy is "joule per mole", so neither will do directly.

What I finally came up with much trial and error was:

type HeatCapacityPerAmountOfSubstance = Quantity<ISQ<P2, P1, N2, Z0, N1, N1, Z0>, SI<f64>, f64>;

However, this is not really user friendly. Perhaps there could be a macro to help with this?

nakedible avatar Jan 01 '20 02:01 nakedible

Another good suggestion. Your code snippet above is the best way currently.

iliekturtles avatar Jan 02 '20 13:01 iliekturtles