pub trait UnitFromType {
// Provided method
fn unit_from_type() -> Unit { ... }
}Expand description
Provided Methods§
Sourcefn unit_from_type() -> Unit
fn unit_from_type() -> Unit
This function derives an Unit from any type which implements
UnitFromType. Its default implementation returns an Unit
where all exponents are zero.
§Examples
use dyn_quantity::UnitFromType;
use uom::si::f64::Length;
// 64-bit floats do not represent a physical quantity
let exp = f64::unit_from_type();
assert_eq!(exp.meter, 0);
// The "Length" type alias from the uom crate represents a physical quantity (length)
let exp = Length::unit_from_type();
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.
Implementations on Foreign Types§
impl UnitFromType for f64
impl UnitFromType for Complex<f64>
Source§impl<L, M, T, I, Th, N, J, K> UnitFromType for Quantity<ISQ<L, M, T, I, Th, N, J, K>, SI<f64>, f64>
Available on crate feature uom only.
impl<L, M, T, I, Th, N, J, K> UnitFromType for Quantity<ISQ<L, M, T, I, Th, N, J, K>, SI<f64>, f64>
Available on crate feature
uom only.