pub trait HasRefUnit:
Quantity
+ Add<Self>
+ Sub<Self>
+ Div<Self>{
const REF_UNIT: <Self as Quantity>::UnitType;
// Provided methods
fn unit_from_scale(amnt: AmountT) -> Option<Self::UnitType> { ... }
fn equiv_amount(&self, unit: Self::UnitType) -> AmountT { ... }
fn convert(&self, to_unit: Self::UnitType) -> Self { ... }
fn convert_assign(&mut self, to_unit: Self::UnitType) { ... }
fn eq(&self, other: &Self) -> bool { ... }
fn partial_cmp(&self, other: &Self) -> Option<Ordering> { ... }
fn add(self, rhs: Self) -> Self { ... }
fn add_assign(&mut self, rhs: Self) { ... }
fn sub(self, rhs: Self) -> Self { ... }
fn sub_assign(&mut self, rhs: Self) { ... }
fn div(self, rhs: Self) -> AmountT { ... }
}Expand description
Trait for quantities having a reference unit
Required Associated Constants§
Provided Methods§
Sourcefn unit_from_scale(amnt: AmountT) -> Option<Self::UnitType>
fn unit_from_scale(amnt: AmountT) -> Option<Self::UnitType>
Returns Some(unit) where unit.scale() == amnt, or None if
there is no such unit.
Sourcefn equiv_amount(&self, unit: Self::UnitType) -> AmountT
fn equiv_amount(&self, unit: Self::UnitType) -> AmountT
Returns factor so that factor * unit == self.
Sourcefn convert(&self, to_unit: Self::UnitType) -> Self
fn convert(&self, to_unit: Self::UnitType) -> Self
Returns qty where qty == self and qty.unit() is to_unit.
Sourcefn convert_assign(&mut self, to_unit: Self::UnitType)
fn convert_assign(&mut self, to_unit: Self::UnitType)
Converts self to the equivalent to_unit.
Sourcefn eq(&self, other: &Self) -> bool
fn eq(&self, other: &Self) -> bool
Returns true, if self and other have equivalent amounts, otherwise
false.
Sourcefn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
Returns the partial order of selfs amount and others eqivalent
amount in selfs unit.
Sourcefn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
Adds the unit-equivalent amount of other to self in place.
Sourcefn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
Subtracts the unit-equivalent amount of other from self in place.
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.