-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unclear about how to create arbitrary quantities with arbitrary units #464
Comments
I didn't have a chance to fully go through your code and try to compile locally to resolve the errors. My guess right now is that type constraints are missing and compiler isn't explicitly calling them out. Is there any reason you want to store the data as |
@iliekturtles Thanks for looking into this. The arrays in this code are a standin for |
@iliekturtles That being said, is there a way to convert an |
I have had a hard time understanding how to get |
If you know the quantity ( use uom::si::length as l;
use uom::si::*;
fn main() {
let x = Quantity::<l::Dimension, SI<f32>, f32>::new::<l::meter>(5.0);
println!("{:?}", x); // 5.0 m^1
} |
The issue is that I don't have the quantity available initially. Is there a way to get the mapping between |
I'm new to rust and very new to UOM, so admittedly, this is likely user error caused by a lack of understanding. This is a followup from my StackOverflow post, which got no traction unfortunately.
I am trying to make a simple type that will be backed by an array in the default units of a given dimension. The idea is pretty simple: I provide a constructor that converts quantities to base units and getters that convert them back to desired units for some given dimension:
I end up with a couple of different errors that I can't quite make sense of:
I am having trouble understanding what is going on here because I was under the impression that there is a blanket implementation of
new
forQuantity
, but apparently that's not the case.If I comment out the lines with
Quantity::<D, SI<f64>, f64>::new::<U>(...).value,
, e.g. like0.0, //Quantity::<D, SI<f64>, f64>::new::<U>(x).value,
, the debug error still persists:I have had a hard time finding a good tutorial for UOM. My issue is that while the crate is well documented and thorough, it appears to assume a certain level of prior knowledge that I simply don't have.
The text was updated successfully, but these errors were encountered: