How can you specify a `uom` type (`Quantity`) with arbitrary dimensions?

For example, imagine that at some point in my code I want/need to declare that some value has units of length-1, or mass3✕current2✕time-2. Rather than tracking down some pre-existing named `Quantity` with those dimensions (which, in general, won't exist) I'd like to state in a not-too-verbose way that the dimensions of this quantity right here are these. Close to ideal would be something like:

``````let foo: Quantity<L = N1> = todo!();
let bar: Quantitiy<M = P3, I = P2, T = N2> = todo!();
``````

and I couldn't really ask for better than

``````let foo: units!(L = 1) = todo!();
let bar: units!(M = 3, I = 2, T = -2) = todo!();
``````

Is it possible to specify ad-hoc quantities at all?

It is possible. The two examples above could be expressed as

``````use uom::{si::{ISQ, SI, Quantity}, typenum::{Z0, N1, N2, P2, P3}};

let foo: Quantity<ISQ<N1, Z0, Z0, Z0, Z0, Z0, Z0>, SI<f32>, f32> = todo!();
let bar: Quantity<ISQ<Z0, P3, P2, N2, Z0, Z0, Z0>, SI<f32>, f32> = todo!();
``````

Now let's see if I can find a more user-friendly way of doing it.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.