#unit #prefix #si #parse #serde

si-unit-prefix

SI Unit Prefix enum impl as_f64/f32, as_exp, parse_from_str with serde support

1 stable release

1.0.0 Oct 8, 2022

#655 in Science

Download history 5/week @ 2023-12-03 8/week @ 2023-12-10 26/week @ 2023-12-17 10/week @ 2023-12-24 39/week @ 2023-12-31 23/week @ 2024-01-07 15/week @ 2024-01-14 6/week @ 2024-01-21 15/week @ 2024-01-28 36/week @ 2024-02-04 17/week @ 2024-02-11 51/week @ 2024-02-18 44/week @ 2024-02-25 24/week @ 2024-03-03 88/week @ 2024-03-10 34/week @ 2024-03-17

196 downloads per month

MIT license

8KB
153 lines

SI Unit Prefix

This library is ideal for simple Rust handling of SI unit prefixes.

Features

  • You can use SiUnitPrefix::G to represent "Giga".
    • Supported: "Q" "R" "Y" "Z" "E" "P" "T" "G" "M" "k" "h" "da" "d" "c" "m" "u" "n" "p" "f" "a" "z" "y" "r" "q"
      • Extra: "㌐" "㍋" "㌔" "㌥" "㌢" "㍉" "㍃" "㌨" "㌰"
  • .as_f64(): eg. SiUnitPrefix::G.as_f64() -> 1e+9f64
  • .as_f32(): eg. SiUnitPrefix::G.as_f32() -> 1e+9f32
  • .as_exp(): eg. SiUnitPrefix::G.as_exp() -> 9i8
  • .parse(str): eg. SiUnitPrefix::parse_from_str("G") -> SiUnitPrefix::G
  • with devies:
    • serde::Serialize/serde::Deserialize
    • Clone/Copy
    • PartialEq/Eq
    • PartialOrd/Ord
    • Debug

Examples/Tests

See tests/test.rs file. It's so simple. :)

License

MIT

Author

Dependencies

~0.5–1MB
~24K SLoC