Struct yaiouom::RuntimeUnit [] [src]

pub struct RuntimeUnit { /* fields omitted */ }

Runtime representation of a unit.

Used mainly for debug assertions and for debug formatting.

Methods

impl RuntimeUnit
[src]

[src]

Display a RuntimeUnit as a string.

Positives come before negatives, but otherwise, the order of elements is not specified. A dimensionless unit returns "".

use yaiouom::*;
use yaiouom::si::*;

let unit_str = Mul::<Meter, Inv<Second>>::as_runtime().to_string();
assert_eq!(&unit_str, "m * s^-1");

let unit_str_2 = Mul::<Inv<Second>, Meter>::as_runtime().to_string();
assert_eq!(&unit_str_2, "m * s^-1");

let unit_str_3 = Mul::<Inv<Second>, Mul<Inv<Second>, Meter>>::as_runtime().to_string();
assert_eq!(&unit_str_3, "m * s^-2");

let unit_str_4 = Mul::<Inv<Ampere>, Mul<Inv<Second>, Meter>>::as_runtime().to_string();
assert!(["m * s^-1 * A^-1", "m * A^-1 * s^-1"].iter().any(|x| *x == &unit_str_4));

Performance note

This method is fine for debugging, but should not be used in a tight loop.

Trait Implementations

impl PartialEq for RuntimeUnit
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

[src]

This method tests for !=.

impl Eq for RuntimeUnit
[src]

impl Debug for RuntimeUnit
[src]

[src]

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl Send for RuntimeUnit

impl Sync for RuntimeUnit