Distances
First we’ll look at Distance
. Distance
and Current
are super similar, they
just have different families, so there’s no point in looking at both of them.
We can get the actual value of the current as so:
And if we want to get the unit that was provided:
We can convert between the units in two different ways:
All expected mathematical operations are defined:
Note that all of these operations are non-mutating, the value of tenMM
never
changes, instead, you need to store the results of the operations, and use the
new output instead.
These operations are also written to avoid making allocation where possible,
which means, where possible, tenMM
will be returned, rather than a new
Distance
.
Finally, all operations involving more than one ReifiedUnit
value, result in a
ReifiedUnit
with a unit
of the left hand side, so if you chain a whole bunch
of operations on a Distance
with unit
DistanceUnits.METER
, then the result
should also have unit
DistanceUnits.METER
.
Comparisons are also defined: