pub struct LogosQuantity {
pub q: Quantity,
pub unit: Unit,
}Expand description
A physical quantity on the compiled-to-Rust path — the AOT mirror of the interpreter’s
Quantity value. The magnitude rides the exact rational tower (no float drift) and the display
unit travels with it so Show renders faithfully (42/127 ft). + − require the same
dimension — the front-end’s type checker proves this, so a mismatch is a compile error, not a
runtime one; the runtime check here is a defensive backstop. × ÷ combine dimensions, and a
quantity may be scaled by a dimensionless number (unit preserved).
Fields§
§q: Quantity§unit: UnitImplementations§
Source§impl LogosQuantity
impl LogosQuantity
Sourcepub fn of(value: i64, unit_name: &str) -> Self
pub fn of(value: i64, unit_name: &str) -> Self
value of the named unit (LogosQuantity::of(2, "inch")).
Sourcepub fn from_rational(value: LogosRational, unit_name: &str) -> Self
pub fn from_rational(value: LogosRational, unit_name: &str) -> Self
An exact-rational magnitude of the named unit. Panics on an unknown unit, which the front-end has already rejected before codegen.
pub fn add(&self, other: &LogosQuantity) -> LogosQuantity
pub fn sub(&self, other: &LogosQuantity) -> LogosQuantity
Sourcepub fn mul(&self, other: &LogosQuantity) -> LogosQuantity
pub fn mul(&self, other: &LogosQuantity) -> LogosQuantity
× ÷ combine dimensions; the result is shown in SI/dimension form (empty display unit).
pub fn div_exact(&self, other: &LogosQuantity) -> LogosQuantity
Sourcepub fn scale(&self, k: &LogosRational) -> LogosQuantity
pub fn scale(&self, k: &LogosRational) -> LogosQuantity
Scale by a dimensionless number (unit preserved): q * k.
Sourcepub fn scale_int(&self, k: i64) -> LogosQuantity
pub fn scale_int(&self, k: i64) -> LogosQuantity
Scale by a dimensionless integer (unit preserved) — the common q * 3 case from codegen.
Sourcepub fn div_int(&self, k: i64) -> LogosQuantity
pub fn div_int(&self, k: i64) -> LogosQuantity
Divide by a dimensionless integer (unit preserved) — the common q / 2 case from codegen.
Sourcepub fn div_scalar(&self, k: &LogosRational) -> LogosQuantity
pub fn div_scalar(&self, k: &LogosRational) -> LogosQuantity
Divide by a dimensionless number (unit preserved): q / k.
Sourcepub fn convert(&self, unit_name: &str) -> LogosQuantity
pub fn convert(&self, unit_name: &str) -> LogosQuantity
Re-express in another unit of the SAME dimension. A different dimension is the forbidden cast — the type checker rejects it, so this panic is a defensive backstop.
Trait Implementations§
Source§impl Clone for LogosQuantity
impl Clone for LogosQuantity
Source§fn clone(&self) -> LogosQuantity
fn clone(&self) -> LogosQuantity
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LogosQuantity
impl Debug for LogosQuantity
Source§impl Display for LogosQuantity
impl Display for LogosQuantity
Source§impl PartialEq for LogosQuantity
impl PartialEq for LogosQuantity
Source§impl PartialOrd for LogosQuantity
impl PartialOrd for LogosQuantity
impl Eq for LogosQuantity
Auto Trait Implementations§
impl Freeze for LogosQuantity
impl RefUnwindSafe for LogosQuantity
impl Send for LogosQuantity
impl Sync for LogosQuantity
impl Unpin for LogosQuantity
impl UnsafeUnpin for LogosQuantity
impl UnwindSafe for LogosQuantity
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,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.