Trait measurements::Measurement[][src]

pub trait Measurement {
    fn get_base_units_name(&self) -> &'static str;
fn as_base_units(&self) -> f64;
fn from_base_units(units: f64) -> Self; fn get_appropriate_units(&self) -> (&'static str, f64) { ... }
fn pick_appropriate_units(
        &self,
        list: &[(&'static str, f64)]
    ) -> (&'static str, f64) { ... } }

All measurements implement this.

It provides conversion functions to and from raw numbers.

Required Methods

Return the base unit for this type, as a string. For example "kilograms"

Get this quantity in the base units

Create a new quantity from the base units

Provided Methods

Returns a string containing the most appropriate units for this quantity, and a floating point value representing this quantity in those units. Useful when, for example, a length might be in millimeters if it is very small, or kilometers when it is very large.

The default implementation always selects the base unit. Override in your Measurement impl to select better units if required.

Given a list of units and their scale relative to the base unit, select the most appropriate one.

The list must be smallest to largest, e.g. ("nanometre", 10-9) to ("kilometre", 10e3)

Implementations on Foreign Types

impl Measurement for Duration
[src]

Implementors