5 releases

Uses new Rust 2024

0.2.2 Jul 10, 2025
0.2.1 Jul 9, 2025
0.2.0 Jul 8, 2025
0.1.1 Jul 7, 2025
0.1.0 Sep 14, 2024

#181 in Value formatting

Download history

209 downloads per month

MIT/Apache

32KB
508 lines

MSuk-SciFi

Some units and stuff I use in a project or two...

Distance

  • Km
  • Mi (... for convenience of some people).
  • Au
  • Ly
  • Pc

Temperature

All temperature implementation(s) work with everything that complies with <T: Into<f64>.

  • K

Functionality

  • add, sub, mul, div
  • try_as_…(), as_…(), as_rounded_…()
  • ratio_with(…)

Examples

#[cfg(test)]
mod msuk_k_testing {
  #[test]
  fn testing_calculus() {
    use msuk_scifi::unit::temperature::k::K;
    let k1 = K::from(100);
    assert_eq!(100.0, k1.value());
    let k2 = K::from(10);
    assert_eq!(10.0, k2.value());
    let f_32 = 32.0_f32;
    let f_64 = 64.0;
    let k3 = k1 + k2;
    assert_eq!(110.0, k3.value());
    let k4_1 = f_32 + k1;
    assert_eq!(132.0, k4_1.value());
    let k4_2 = f_32 - k1;
    // 0K clamp should happen:
    assert_eq!(0.0, k4_2.value());
    let k5 = k1 * f_64;
    assert_eq!(6_400.0, k5.value());
    let k6 = k1 / k2;
    assert_eq!(10.0, k6.value());
  }
}

Mass

  • EarthMass

Dependencies

~1.3–4MB
~77K SLoC