dims_macro
This will allow for easy creation of storage values like distance or mass, as well as preventing adding grams to feet.
The intent is for these values to be kept in-memory as Mass or Length, without having to worry about the unit except for creation of the value, and when accessing it (for display, storage, etc).
IMPORTANT
This is still a Work-In-Progress. Expect rough-edges, but I am working to smooth them out.
System and Unit Creation
These particular systems are already set up already in dims, but you can set up your own systems:
use dims_macro;
// You can use this macro to generate a full system.
// It requires a length for use as debug.
measure_system!;
// Allow for conversion between the systems
// Multiple `MultiplyBy` and `DivideBy` traits can be applied for each `MeasureSystem`
measure_system!;
measure_system!;
// Set up some units, now
pub const FAHRENHEIT: = UnitSimple ;
pub const CELCIUS: = UnitSimple ;
pub const FOOT: = UnitSimple ;
pub const SQUARE_FOOT: = UnitSimple ;
This also contains the si_unit! macro, which will generate a whole set (or individual) SI units with the given info.
TODO: EXAMPLE
MeasureSystem macro
This is used to easily generate a new measuring system with used as:
measure_system!
Expands to (with absolute paths):
;
The DEBUG_UNIT is how the value will be displayed when debugging. This could be how you want to display it, but that should be specified explicitly by consuming code.
Other Notes
Crate options for dims and dims_core
Crate options for dims and dims_macro
-
str(default) will utilizeUnitFormatand store:abbr: Abbreviated unit name (morft)singular: Singular name of a unit (metreorfoot)plural: Plural name of the unit (metresorfeet)
-
stdis the default option, and defaults to using the standard library.
This enables theUnitFormatTrait(as the functions returnString), butno_stdcan still be used withstr(see below) to store the unit name info.