Introducing Whippyunits - Rust dimensional analysis for applied computation

⚓ Rust    📅 2025-11-17    👤 surdeus    👁️ 10      

surdeus

Been working on this for a few months now, and I think it's mature enough to present to the world:

Introducing Whippyunits: Rust dimensional analysis for applied computation

Unlike uom, Whippyunits supports arbitrary dimensional algebra with zero declarative overhead, guaranteeing type and scale safety at all times. Whippyunits comes with:

  • Flexibile declarator syntax
    • 1.0.meters()
    • quantity!(1.0, m)
    • 1.0m (in scopes tagged w/ culit attribute)
  • Lossless rescaling via log-scale arithmetic and lookup-table exponentiation
  • Normalized representation of every derived SI quantity, including angular units
  • Powerful DSL via "unit literal expressions", capable of handling multiple syntaxes (including UCUM)
  • Dimensionally-generic programming which remains dimension- and scale-safe
  • Detailed developer tooling
    • LSP proxy prettyprints Quantity types in hover info and inlay hints
    • CLI prettifier prettyprints Quantity types in rustc compiler messages

and much more!

For now, Whippyunits requires the [generic-const-expressions] unstable nightly feature; a stable typemath polyfill is in the works, but the GCE implementation will still be faster and is perfectly robust (it uses only nonrecursive/bounded integer arithmetic, and does not ever force the trait checker to evaluate algebraic equivalence).

1 post - 1 participant

Read full topic

🏷️ Rust_feed