Crate unitage

Source
Expand description

Latest Release pipeline status coverage report

§Description

Yet one more another unit/dimension support library for rust.

This package lets you write units of physical quantities in the same way you always write it.

§Usage

use ::unitage:: { *, predefined::* };

fn bmi(hight: Length<f64>, weight: Mass<f64>) -> f64 {
    let bmi = weight / hight / hight;

    unit!("kg/m2").value(bmi)
}

let h = pq!(5f64, "ft.") + pq!(8f64, "in.");
let w = pq!(200f64, "lb");

assert_eq!(bmi(h, w), 30.409583894427303); // Lose weight!!

§Package Structure

This package is a entry points for each implementation packages.

For details following topics, please refer the documentation of each sub-package.

Re-exports§

pub use physical_quantity;
pub use const_frac;
pub use typenum;
pub use unit_proc;
pub use real_proc;

Modules§

predefined
traits

Macros§

dim
Generate Dim from unit string.
frac
Generate Frac from decimal numerical literal. When the argument is illegal, compile will fail.
pq
Generate PhysicalQuantity from value and unit string.
unit
Generate Unit from unit string.

Structs§

Conv
linear convertion coefficients target_unit = a * source_unit_value + b
Dim
Static (compile time) Dimension.
DynDim
Dynamic (runtime) Dimension
Frac
Representation of fractional value.
PhysicalQuantity
Represents physical quantity
Unit
Representation of Unit

Traits§

Dimension
Real
Requirements for a type which represents real value.