pub enum UnitScale {
Literal(RationalInteger),
Unresolved {
written: String,
segments: Vec<String>,
name: String,
coefficient: RationalInteger,
exponent: i32,
},
Reference {
target: ReferenceTarget,
coefficient: RationalInteger,
exponent: i32,
},
}Expand description
Conversion factor of a measure unit: a plan-time rational, or a data/rule reference whose value is known only during evaluation.
Dynamic scales carry a plan-time coefficient and exponent so compound
units can inherit a base unit’s reference:
effective = settled(reference)^exponent * coefficient.
Plain -> unit gbp: rate uses coefficient 1 and exponent 1.
-> unit gbp_per_kg: gbp/kilogram uses the gbp reference with
coefficient 1/kilogram and exponent 1.
Variants§
Literal(RationalInteger)
1 of this unit equals this many canonical units.
Unresolved
Written path between parse and classification (rate, fx.rate). The
declaring spec’s type resolution replaces it with Self::Reference or a
compound literal factor; it never survives type resolution.
Fields
coefficient: RationalIntegerReference
Resolved number data field or rule, in the coordinates of the spec whose
type resolution wrote it: a local data or rule, or uses hops plus a member
of the imported spec. After planning succeeds every dynamic unit is this
variant — never Self::Unresolved.
Implementations§
Source§impl UnitScale
impl UnitScale
pub fn dynamic_coefficient(&self) -> Option<&RationalInteger>
pub fn dynamic_exponent(&self) -> Option<i32>
Trait Implementations§
impl Eq for UnitScale
impl StructuralPartialEq for UnitScale
Auto Trait Implementations§
impl Forget for UnitScale
impl Freeze for UnitScale
impl Move for UnitScale
impl RefUnwindSafe for UnitScale
impl Send for UnitScale
impl Sync for UnitScale
impl Unpin for UnitScale
impl UnsafeUnpin for UnitScale
impl UnwindSafe for UnitScale
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.