pub trait AsUnitExponents {
// Provided method
fn as_unit_exponents() -> UnitExponents { ... }
}Expand description
A trait to derive UnitExponents from a type. This trait bridges the gap
between (external) types representing physical quantities (such as e.g. the
Quantity type from
the uom crate) and UnitExponents.
Provided Methods§
Sourcefn as_unit_exponents() -> UnitExponents
fn as_unit_exponents() -> UnitExponents
This function derives an UnitExponents from any type which implements
AsUnitExponents. Its default implementation returns an UnitExponents
where all exponents are zero.
§Examples
use dyn_quantity::AsUnitExponents;
use uom::si::f64::Length;
// 64-bit floats do not represent a physical quantity
let exp = f64::as_unit_exponents();
assert_eq!(exp.meter, 0);
// The "Length" type alias from the uom crate represents a physical quantity (length)
let exp = Length::as_unit_exponents();
assert_eq!(exp.meter, 1);Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.