pub trait Unit:
Copy
+ PartialEq
+ Debug
+ 'static {
type Dim: Dimension;
const RATIO: f64;
const SYMBOL: &'static str;
}Expand description
Trait implemented by every unit type.
-
RATIOis the conversion factor from this unit to the canonical scaling unit of the same dimension. Example: if metres are canonical (Meter::RATIO == 1.0), then kilometres useKilometer::RATIO == 1000.0because1 km = 1000 m. -
SYMBOLis the printable string (e.g."m"or"km"). -
Dimties the unit to its underlyingDimension.
§Invariants
- Implementations should be zero-sized marker types (this crate’s built-in units are unit structs with no fields).
RATIOshould be finite and non-zero.
Required Associated Constants§
Sourceconst SYMBOL: &'static str
const SYMBOL: &'static str
Printable symbol, shown by core::fmt::Display.
Required Associated Types§
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.