Example on embedding into a struct?
Hi there,
I'm considering using uom for hifitime and nyx, but I would like to be able to specify that a given structure stores the data in a given time.
For example, in hifitime, I have an Epoch simply defined as pub struct Epoch(f64);. I'm trying to store a second (e.g. pub struct Epoch(si::time::second);). However, the documentation and the examples don't seem to help me much as to how I should define this structure.
How would I go about implementing that?
Thanks
uom works in quantities (time, length, ...) rather than units (second, meter, ...) so you don't put a second member in your struct, but a Time member. Quantities store their value using the base unit, which in this case is second, so you can just include a Time member.
If you happened to want storage to use a different base unit you can define new type aliases with the ISQ! macro as shown in https://github.com/iliekturtles/uom/blob/master/examples/base.rs.
Long term I'm looking to change the decision of always working with quantities. See #107 for the details and some of the work that I've done.
It's not really clear from the documentation the type of, for example, Length::new::<meter>(15.0); or Time::new::<second>(10.0), an example with explicit types would make this clearer