pub trait FixedSliceQuantity<UnitType: Unit, Element> {
// Required methods
fn unit(&self) -> UnitType;
fn values(&self) -> &[Element];
fn values_mut(&mut self) -> &mut [Element];
fn len(&self) -> usize;
fn convert(&self, unit: UnitType) -> Self;
fn convert_mut(&mut self, unit: UnitType);
fn try_convert(&self, unit: Units) -> Result<Self, RuntimeUnitError>
where Self: Sized;
}Expand description
Trait that implements conversion of a slice quantity within a given unit type (e.g. m->cm, kg->g)
Required Methods§
Sourcefn values_mut(&mut self) -> &mut [Element]
fn values_mut(&mut self) -> &mut [Element]
Return mutable values in quantity
Sourcefn convert(&self, unit: UnitType) -> Self
fn convert(&self, unit: UnitType) -> Self
Convert a unit of one UnitType to another of the same type. No validation of base unit is made.
Sourcefn convert_mut(&mut self, unit: UnitType)
fn convert_mut(&mut self, unit: UnitType)
Mutate current quantity, convering a unit of one UnitType to another of the same type. No validation of base unit is made.
Sourcefn try_convert(&self, unit: Units) -> Result<Self, RuntimeUnitError>where
Self: Sized,
fn try_convert(&self, unit: Units) -> Result<Self, RuntimeUnitError>where
Self: Sized,
Attempt to convert the unit given in unit to a UnitType. Base unit validation is made here.
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.