Skip to main content

Module units

Module units 

Source
Expand description

Compile-time dimensional analysis for physical quantities. Compile-time dimensional analysis for physical quantities.

This module provides type-safe physical quantity tracking using phantom types and typenum type-level integers. Named newtypes like Force, Voltage, and Energy produce clear compiler error messages (“expected Force, found Mass”) while the generic Qty type handles exotic dimension combinations.

§Architecture

  • Named newtypes (30 types): Force, Voltage, Energy, etc. — best error messages
  • Generic Qty<D>: Fallback for intermediate/exotic dimensions — uses typenum Dim
  • Blanket Mul/Div: Any Qty<D1> * Qty<D2> computes output dimension via typenum
  • dim! macro: Ergonomic dimension-checked arithmetic: dim!(ctx, Force: m * a)
  • assert_dim!: Compile-time checkpoint assertions
  • const_assert_dim!: Compile-time formula verification with custom error messages

Re-exports§

pub use dim::*;
pub use qty::*;
pub use si::*;
pub use calculus::*;
pub use inference::*;

Modules§

assert_macros
Compile-time dimension-assertion macros (assert_dim!, const_assert_dim!). Compile-time dimension assertion macros.
calculus
Dimensional calculus: differentiation and integration that track dimensions. Dimensional calculus: differentiation and integration that track physical dimensions through the type system.
constants
Physical constants as dimension-typed symbolic expressions. Physical constants as dimension-typed symbolic expressions.
conv_factors
Exact conversion factor constants with derivation verification tests. Exact conversion factor constants for unit conversions.
conversions
Unit-conversion helpers between SI prefixes and common non-SI units. Unit conversion constructors and getters for named quantity types.
dim
Dimension vectors: phantom-typed compile-time SI dimension tracking. Dimension vectors: phantom-typed compile-time SI dimension tracking.
inference
Runtime dimension inference for expression trees. Runtime dimension inference for symbolic expressions.
qty
Generic dimensioned quantity wrapper and arithmetic operators. Generic dimensioned quantity wrapper.
si
Named SI newtypes (e.g. Force, Voltage, Energy) with constructor helpers. Named newtype wrappers for 30 SI physical quantities.