pub struct UnitRegistry { /* private fields */ }Expand description
Unit registry: maps unit names to UnitInfo (dimension + scale).
Implementations§
Source§impl UnitRegistry
impl UnitRegistry
Sourcepub fn get_unit(&self, name: &UnitRef) -> Option<&UnitInfo>
pub fn get_unit(&self, name: &UnitRef) -> Option<&UnitInfo>
Look up a unit by reference (bare or module-alias-qualified).
Sourcepub fn all_units(
&self,
) -> impl Iterator<Item = (&UnitRef, &Dimension, &UnitScale)>
pub fn all_units( &self, ) -> impl Iterator<Item = (&UnitRef, &Dimension, &UnitScale)>
Iterate over all units: (reference, dimension, scale).
Sourcepub fn resolve_unit_expr(
&self,
expr: &UnitExpr,
) -> Result<(Dimension, f64), UnitResolveError>
pub fn resolve_unit_expr( &self, expr: &UnitExpr, ) -> Result<(Dimension, f64), UnitResolveError>
Resolve a UnitExpr to its dimension and compound static scale factor.
§Errors
Returns a UnitResolveError naming the unknown or dynamic-scale
unit, or the exponent overflow.
Sourcepub fn resolve_unit_dimension(
&self,
expr: &UnitExpr,
) -> Result<Dimension, UnitResolveError>
pub fn resolve_unit_dimension( &self, expr: &UnitExpr, ) -> Result<Dimension, UnitResolveError>
Resolve a UnitExpr to its dimension only (ignoring scales).
Works for both static and dynamic units.
§Errors
Returns a UnitResolveError naming the unknown unit, or the
exponent overflow.
Trait Implementations§
Source§impl Clone for UnitRegistry
impl Clone for UnitRegistry
Source§fn clone(&self) -> UnitRegistry
fn clone(&self) -> UnitRegistry
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for UnitRegistry
impl RefUnwindSafe for UnitRegistry
impl Send for UnitRegistry
impl Sync for UnitRegistry
impl Unpin for UnitRegistry
impl UnsafeUnpin for UnitRegistry
impl UnwindSafe for UnitRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more