joto_format 0.1.0

Fast, const-safe formatter for SI, US Customary, and typesetting dimensions with exactness tracking.
Documentation
  • Coverage
  • 60%
    51 out of 85 items documented0 out of 36 items with examples
  • Size
  • Source code size: 109.19 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 6.05 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 13s Average build duration of successful builds.
  • all releases: 13s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • xorgy/joto
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • xorgy

Joto Format

How do you write it down?

dependency status ISC/MIT/Apache 2.0 Build status Crates.io Docs

This package contains const-safe, allocation-free formatting of lengths, masses, and temperatures for working with other joto workspace packages.

In this workspace, IOTA is defined as one ninth of a nanometer, WHIT as 1⁄3200 µg, and SMIDGE as 1⁄90 mK. Formatting uses these integer base units and displays them as mixed-unit strings with exactness tracking.

Examples

Basic usage

use joto_constants::length::u64::MILLIMETER;
use joto_format::length::u64::format_dim;
use joto_format::length::{LengthFormat, Unit};

let o = format_dim(12345 * MILLIMETER, Unit::Meter, LengthFormat::new());
assert_eq!(o.as_str(), "12.345m");
assert!(o.exact);

Exactness

Formatting results include an exact field which indicates whether the value is exactly represented by the formatted string.

use joto_constants::mass::u64::MICROGRAM;
use joto_format::mass::u64::format_dim;
use joto_format::mass::{MassFormat, Unit};

let o = format_dim(MICROGRAM + MICROGRAM / 1000, Unit::Microgram, MassFormat::new());
assert_eq!(o.as_str(), "1µg");
assert!(!o.exact);

Minimum Supported Rust Version (MSRV)

This version of joto_format has been verified to compile with Rust 1.83 and later.

Future versions might increase the Rust version requirement. It will not be treated as a breaking change, and as such can even happen with small patch releases.

License

Triple licensed, at your option:

Contribution

Contributions are welcome by pull request or email. Please feel free to add your name to the AUTHORS file in any substantive pull request.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.