Skip to main content

UnitSqrt

Trait UnitSqrt 

Source
pub trait UnitSqrt: Unit {
    type Root: Unit;
}
Expand description

Inverse of squaring at the type level: maps a “squared” unit back to its scalar root unit.

Implemented blanketly for Prod<U, U>, so any unit that arises as the dimensional square of another unit (e.g. Prod<Meter, Meter>SquareMeter) carries a Root = U and can be square-rooted via Quantity::sqrt.

This is the dimensionally correct inverse of the Quantity<U> * Quantity<U> -> Quantity<Prod<U, U>> Mul impl provided through UnitMul.

§Note

The blanket impl deliberately only covers the symmetric product Prod<U, U>; mixed products like Prod<Meter, Second> have no well-defined square root in this system.

Required Associated Types§

Source

type Root: Unit

The unit obtained by taking the dimensional square root of Self.

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.

Implementors§

Source§

impl<U: Unit> UnitSqrt for Prod<U, U>
where U::Dim: DimMul<U::Dim>, <U::Dim as DimMul<U::Dim>>::Output: Dimension,

Source§

type Root = U