You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes we want to sort a list of physical quantities. For such purpose, ordered_float is useful; we want to handle with Vec<Meter<OrderedFloat<f64>>>. However, useful constants like M and KG are defined only for primitive types, so there seems no really easy way to multiply quantities. Any idea how to deal with such situation? Currently I'm thinking of making a module named ordered_float_f64_consts or something, copying entire contents of f64consts (expanded by cargo-expand) to my project. Maybe it would be useful if this library provides a macro for defining arbitrary-type constants for existing unit system.
Thanks for this amazing project, by the way! I'm enjoying exploring the type-safety world of physical computations.
The text was updated successfully, but these errors were encountered:
I like the idea of allowing custom types for consts-generation. I'm (slowly) rewriting dimensioned to use proc-macros, so now is probably not the best time to add it.
It doesn't get you all the functionality you want, but you could define a trait to inject OrderedFloat inside a, say, SI type:
Thanks. That's indeed the most sensible way to do that. Another problem is that it is hard to do arithmetic operations between ordered-float-si-values, but maybe we should unwrap them before calculating, and only use the wrapped value when storing into, say, vecs or btreemaps?
Sometimes we want to sort a list of physical quantities. For such purpose,
ordered_float
is useful; we want to handle withVec<Meter<OrderedFloat<f64>>>
. However, useful constants likeM
andKG
are defined only for primitive types, so there seems no really easy way to multiply quantities. Any idea how to deal with such situation? Currently I'm thinking of making a module namedordered_float_f64_consts
or something, copying entire contents off64consts
(expanded by cargo-expand) to my project. Maybe it would be useful if this library provides a macro for defining arbitrary-type constants for existing unit system.Thanks for this amazing project, by the way! I'm enjoying exploring the type-safety world of physical computations.
The text was updated successfully, but these errors were encountered: