Trait FixedSliceQuantity

Source
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§

Source

fn unit(&self) -> UnitType

Return unit associated with this quantity

Source

fn values(&self) -> &[Element]

Return values in quantity

Source

fn values_mut(&mut self) -> &mut [Element]

Return mutable values in quantity

Source

fn len(&self) -> usize

Return number of values in quantity

Source

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.

Source

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.

Source

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.

Implementors§