Skip to content

v0.16.0

Choose a tag to compare

@iliekturtles iliekturtles released this 21 Dec 19:33

This release contains significant changes in order to support underlying storage types that implement the Num trait beyond f32 and f64. Many changes are breaking: marker traits are simplified and fewer macros are exported. New storage types are not enabled by default and can be used by including the corresponding feature. See the changes below for full details.

Added

  • Add missing #[derive(Hash)] attributes.
  • #29 A new macro, storage_types!, is now available to duplicate code on a per-storage type basis. See macro documentation for full details. The minimum supported rustc version is now 1.20.0.

Changed

  • #29 Underlying storage type now uses the Num trait from the num crate instead of fixed implementations for f32 and f64. Features for all types implementing Num have been added and control the availability of the type as an underlying storage type: usize, u8, u16, u32, u64, isize, i8, i16, i32, i64, bigint, biguint, rational, rational32, rational64, bigrational, f32, and f64. For compile time reasons only f32 and f64 are enabled by default. Tests are implemented for all underlying storage types but don't account for minimum or maximum values and will fail for non-float types where the conversion factor overflows the type's limits. A future release will correct this.
  • #29 [Breaking] Traits and structs generated by the system! macro have been significantly changed in order to support non-float underlying storage types.
    • Dimension changed to directly include associated types for quantity dimensions.
    • Units<V> is now only parameterized on V and contains associated types for base units.
    • Conversion<V> has been removed and replaced with uom::Conversion<V>.
    • $quantities<...> has been removed. Quantity dimensions are now directly in the Dimension trait.
    • BaseUnits<...> has been removed. Base units are not directly in the Units<V> trait.
    • uom::Conversion<V> added to replace Conversion<V> and gives access to a unit's conversion factor.
    • uom::ConversionFactor<V> added to represent conversion factors for underlying storage types where the type can't be used (e.g. i32's conversion factor is represented as Rational32.)
  • [Breaking] Macro usage and definitions have been simplified and consolidated. quantities!, replace_ty!, and unit! have been consolidated as "private" match arms of their calling macro. In order to reduce the chance of macro name collisions $quantities! is the only remaining generated exported macro (e.g. ISQ! for the si system). Generated macros for each quantity no longer exist. These changes make it easier to have multiple systems containing quantities with the same names. In order to support this change quantities in the units block of the system! macro must always be prefixed by the quantity's module (e.g. length::Length). Prefixing the module with the mod keyword instructs the system! macro not to generate a #[macro_use] pub mod $module; statement.