pub trait Unit:
Copy
+ Eq
+ PartialEq
+ Sized
+ Mul<AmountT>
+ Display {
type QuantityType: Quantity<UnitType = Self>;
// Required methods
fn iter() -> impl Iterator<Item = Self>;
fn name(&self) -> String;
fn symbol(&self) -> String;
fn si_prefix(&self) -> Option<SIPrefix>;
// Provided methods
fn from_symbol(symbol: &str) -> Option<Self> { ... }
fn as_qty(&self) -> Self::QuantityType { ... }
fn fmt(&self, form: &mut Formatter<'_>) -> Result { ... }
}Expand description
The abstract type of units used to define quantities.
Required Associated Types§
Sourcetype QuantityType: Quantity<UnitType = Self>
type QuantityType: Quantity<UnitType = Self>
Associated type of quantity
Required Methods§
Provided Methods§
Sourcefn from_symbol(symbol: &str) -> Option<Self>
fn from_symbol(symbol: &str) -> Option<Self>
Returns Some(unit) where unit.symbol() == symbol, or None if
there is no such unit.
Sourcefn as_qty(&self) -> Self::QuantityType
fn as_qty(&self) -> Self::QuantityType
Returns 1 * self
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".