Skip to main content

QuantityUnit

Trait QuantityUnit 

Source
pub trait QuantityUnit: 'static {
    // Required methods
    fn type_id() -> TypeId;
    fn base_unit() -> &'static str;

    // Provided method
    fn allowed_suffixes() -> &'static [&'static str] { ... }
}
Expand description

Marker trait describing the unit constraints of a Quantity.

Required Methods§

Source

fn type_id() -> TypeId

Stable identifier of this unit, embedded into the Quantity type id.

Source

fn base_unit() -> &'static str

Canonical base unit (e.g. "kg", "m", "s", "B").

Provided Methods§

Source

fn allowed_suffixes() -> &'static [&'static str]

Suffixes accepted on input and rendered on output.

If empty, only QuantityUnit::base_unit is accepted. If non-empty, only the listed suffixes are accepted, so include the base unit here if it should remain valid.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§