Skip to main content

Dimension

Struct Dimension 

Source
pub struct Dimension { /* private fields */ }
Expand description

A physical dimension: a vector of rational exponents over BaseDim. The group operation is mul (axiswise exponent addition); the identity is Dimension::DIMENSIONLESS; the inverse is Dimension::recip.

Implementations§

Source§

impl Dimension

Source

pub const DIMENSIONLESS: Dimension

The identity dimension — the all-zero exponent vector (a pure number, e.g. a count or ratio).

Source

pub fn base(d: BaseDim) -> Dimension

The dimension of a single base axis raised to the first power (e.g. base(Length) = L).

Source

pub fn from_exps(e: [Exp; 10]) -> Dimension

Build a dimension directly from its exponent vector (in BaseDim::ALL order) — the inverse of reading exponent for each axis. Used to reconstruct a dimension from the wire, where the exponents travel as their (numerator, denominator) pairs.

Source

pub fn exponent(self, d: BaseDim) -> Exp

The exponent on a given base axis.

Source

pub fn is_dimensionless(self) -> bool

True for the dimensionless identity (every exponent zero).

Source

pub fn mul(self, other: Dimension) -> Dimension

self × other — axiswise exponent ADDITION (Length × Length = Length²).

Source

pub fn div(self, other: Dimension) -> Dimension

self ÷ other — axiswise exponent SUBTRACTION (Area ÷ Length = Length).

Source

pub fn recip(self) -> Dimension

1 / self — the multiplicative inverse (negate every exponent). Frequency = recip(Time).

Source

pub fn powi(self, k: i32) -> Dimension

self^k — the kth power (scale every exponent). powi(0) is dimensionless.

Source

pub fn nth_root(self, k: i32) -> Dimension

The kth root — divide every exponent by k (nth_root(Area, 2) = Length). Panics for k == 0.

Source

pub fn length() -> Dimension

Source

pub fn mass() -> Dimension

Source

pub fn time() -> Dimension

Source

pub fn current() -> Dimension

Source

pub fn temperature() -> Dimension

Source

pub fn amount() -> Dimension

Source

pub fn luminous() -> Dimension

Source

pub fn angle() -> Dimension

Source

pub fn solid_angle() -> Dimension

Source

pub fn information() -> Dimension

Source

pub fn area() -> Dimension

Source

pub fn volume() -> Dimension

Source

pub fn speed() -> Dimension

Source

pub fn acceleration() -> Dimension

Source

pub fn frequency() -> Dimension

Source

pub fn force() -> Dimension

Source

pub fn energy() -> Dimension

Source

pub fn power() -> Dimension

Source

pub fn pressure() -> Dimension

Source

pub fn charge() -> Dimension

Source

pub fn voltage() -> Dimension

Source

pub fn resistance() -> Dimension

Source

pub fn conductance() -> Dimension

Source

pub fn capacitance() -> Dimension

Source

pub fn magnetic_flux() -> Dimension

Source

pub fn inductance() -> Dimension

Source

pub fn magnetic_flux_density() -> Dimension

Source

pub fn surface_tension() -> Dimension

Source

pub fn density() -> Dimension

Source

pub fn absorbed_dose() -> Dimension

Source

pub fn radioactivity() -> Dimension

Source

pub fn exposure() -> Dimension

Source

pub fn catalytic_activity() -> Dimension

Source

pub fn luminous_flux() -> Dimension

Source

pub fn illuminance() -> Dimension

Source

pub fn luminance() -> Dimension

Source

pub fn data_rate() -> Dimension

Source

pub fn volumetric_flow() -> Dimension

Source

pub fn molar_concentration() -> Dimension

Source

pub fn molality() -> Dimension

Source

pub fn dynamic_viscosity() -> Dimension

Source

pub fn kinematic_viscosity() -> Dimension

Source

pub fn fuel_economy() -> Dimension

Source

pub fn by_name(name: &str) -> Option<Dimension>

Resolve a named dimension (case-insensitive) to its exponent vector — the lookup behind the Quantity of <Dimension> type annotation (Quantity of Length, Quantity of Area). The names are the human dimension words, not units; None for an unknown name.

Trait Implementations§

Source§

impl Clone for Dimension

Source§

fn clone(&self) -> Dimension

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Dimension

Source§

impl Debug for Dimension

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Dimension

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Dimension

Source§

impl Hash for Dimension

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Dimension

Source§

fn eq(&self, other: &Dimension) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Dimension

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.