I'm trying to write another yet physical unit/dimension crate, because none of the crates I've found are generic enough.
After some experiments, I tried using constant generics to represent the exponent of a dimension (L, L², L·T-1, etc.). But I need to do arithmetic with the constant parameters (L¹×L¹=L²).
See a simplified version of my code
It gives the error:
error: constant expression depends on a generic parameter
--> src/lib.rs:23:5
|
23 | type Output = Meter<O, {D + RD}>;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: this may fail depending on what value the parameter takes
error: constant expression depends on a generic parameter
--> src/lib.rs:25:40
|
25 | fn mul(self, rhs: Meter<R, RD>) -> Self::Output {
| ^^^^^^^^^^^^
|
= note: this may fail depending on what value the parameter takes
Is it possible to do that? If not, I will use typenum.