use-units 0.1.0

Cross-domain unit primitives for RustUse.
Documentation
  • Coverage
  • 47.37%
    9 out of 19 items documented1 out of 7 items with examples
  • Size
  • Source code size: 6.67 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 394.01 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 12s Average build duration of successful builds.
  • all releases: 12s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • RustUse/use-units
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • CloudBranch

use-units

Foundational unit descriptors and linear conversion helpers.

use-units provides a compact UnitSpec type for describing compatible units and applying simple linear conversions. It is intended to act as the shared vocabulary layer for future RustUse chemistry, physics, wave, time, finance, and measurement crates.

What this crate provides

Item Purpose
UnitDomain Domain tags for cross-workspace unit families
SUPPORTED_DOMAINS Stable list of the current RustUse unit domains
UnitSpec Small copyable unit descriptor with a scale to a base
convert_value() Compatibility-checked linear conversion helper

Installation

[dependencies]
use-units = "0.1.0"

Example

use use_units::{UnitDomain, UnitSpec};

let second = UnitSpec::new(UnitDomain::Time, "duration", "s", 1.0);
let minute = UnitSpec::new(UnitDomain::Time, "duration", "min", 60.0);

assert_eq!(minute.convert_value(2.0, second), Some(120.0));
assert!(minute.is_compatible_with(second));

Scope

  • Small, auditable metadata types.
  • Linear scaling only.
  • No global registry or domain-specific catalogs yet.