Closed ttencate closed 2 years ago
What's the use of a quantity which has only one unit?
Anyway, you can define a quantity with only one unit when not giving a reference unit:
#[quantity]
#[unit(Bar, "bar")]
struct Foo;
What's the use of a quantity which has only one unit?
To avoid confusion with other quantities, and to combine them into new units. I mean, m and s and their derived units m/s and m/s² would be useful even if kilometers and hours didn't exist, right?
In my concrete use case, I'm working on an optimizer that optimizes for cost, so my quantity is euros, and I'm using other units like €/kWh for energy price and €/m/y for yearly depreciation of conduits.
It's just a small inconvenience, but it seemed to me there was no reason for the restriction.
This does not compile:
Kudos for the clear error message though!
I worked around it by adding an unused dummy unit, but that seems silly.