Struct Quantity

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

A quantity of a unit, supports converting from one unit to another.

Implementations§

Source§

impl Quantity

Source

pub fn new(value: f64, unit: UnitDefinition) -> Self

Create a new instance of Quantity with a given value and unit

Source

pub fn value(&self) -> f64

Amount of unit stored in quantity

Source

pub fn value_mut(&mut self) -> &mut f64

Get mutable reference to the value for this quantity.

Source

pub fn powf(&self, value: f64) -> Quantity

Source

pub fn powi(&self, value: i8) -> Quantity

Source

pub fn inv(&self) -> Quantity

Trait Implementations§

Source§

impl Add<Quantity> for AmountOfSubstance

Source§

type Output = AmountOfSubstance

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Quantity) -> Self

Performs the + operation. Read more
Source§

impl Add<Quantity> for Angle

Source§

type Output = Angle

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Quantity) -> Self

Performs the + operation. Read more
Source§

impl Add<Quantity> for Dimensionless

Source§

type Output = Dimensionless

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Quantity) -> Self

Performs the + operation. Read more
Source§

impl Add<Quantity> for ElectricCurrent

Source§

type Output = ElectricCurrent

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Quantity) -> Self

Performs the + operation. Read more
Source§

impl Add<Quantity> for Length

Source§

type Output = Length

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Quantity) -> Self

Performs the + operation. Read more
Source§

impl Add<Quantity> for Luminance

Source§

type Output = Luminance

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Quantity) -> Self

Performs the + operation. Read more
Source§

impl Add<Quantity> for Mass

Source§

type Output = Mass

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Quantity) -> Self

Performs the + operation. Read more
Source§

impl Add<Quantity> for TemperatureInterval

Source§

type Output = TemperatureInterval

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Quantity) -> Self

Performs the + operation. Read more
Source§

impl Add<Quantity> for Time

Source§

type Output = Time

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Quantity) -> Self

Performs the + operation. Read more
Source§

impl Add for Quantity

Source§

type Output = Quantity

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Quantity) -> Self::Output

Performs the + operation. Read more
Source§

impl AddAssign<Quantity> for AmountOfSubstance

Source§

fn add_assign(&mut self, rhs: Quantity)

Performs the += operation. Read more
Source§

impl AddAssign<Quantity> for Angle

Source§

fn add_assign(&mut self, rhs: Quantity)

Performs the += operation. Read more
Source§

impl AddAssign<Quantity> for Dimensionless

Source§

fn add_assign(&mut self, rhs: Quantity)

Performs the += operation. Read more
Source§

impl AddAssign<Quantity> for ElectricCurrent

Source§

fn add_assign(&mut self, rhs: Quantity)

Performs the += operation. Read more
Source§

impl AddAssign<Quantity> for Length

Source§

fn add_assign(&mut self, rhs: Quantity)

Performs the += operation. Read more
Source§

impl AddAssign<Quantity> for Luminance

Source§

fn add_assign(&mut self, rhs: Quantity)

Performs the += operation. Read more
Source§

impl AddAssign<Quantity> for Mass

Source§

fn add_assign(&mut self, rhs: Quantity)

Performs the += operation. Read more
Source§

impl AddAssign<Quantity> for TemperatureInterval

Source§

fn add_assign(&mut self, rhs: Quantity)

Performs the += operation. Read more
Source§

impl AddAssign<Quantity> for Time

Source§

fn add_assign(&mut self, rhs: Quantity)

Performs the += operation. Read more
Source§

impl AddAssign for Quantity

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl ArbitraryQuantity for Quantity

Source§

fn unit(&self) -> UnitDefinition

Return unit associated with this quantity
Source§

fn convert(&self, unit: UnitDefinition) -> Quantity

Convert from this unit to another (creates a copy). No validation of base unit is made.
Source§

fn try_convert_mut( &mut self, unit: UnitDefinition, ) -> Result<(), RuntimeUnitError>

Try to convert from this unit to another (modifies current quantity)
Source§

fn convert_mut(&mut self, unit: UnitDefinition)

Convert from this unit to another (modifies current quantity). No validation of base unit is made.
Source§

fn try_convert( &self, unit: UnitDefinition, ) -> Result<Quantity, RuntimeUnitError>

Try to convert from this unit to another (creates a copy)
Source§

fn unit_mut(&mut self) -> &mut UnitDefinition

Return unit associated with this quantity (mutable)
Source§

fn try_convert_unit(&self, unit: Units) -> Result<Self, RuntimeUnitError>

Try to convert from this unit to the given unit (creates a copy)
Source§

impl Clone for Quantity

Source§

fn clone(&self) -> Quantity

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Quantity

Source§

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

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

impl Display for Quantity

Source§

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

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

impl Div<f64> for Quantity

Source§

type Output = Quantity

The resulting type after applying the / operator.
Source§

fn div(self, rhs: f64) -> Self::Output

Performs the / operation. Read more
Source§

impl Div for Quantity

Source§

type Output = Quantity

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Quantity) -> Self::Output

Performs the / operation. Read more
Source§

impl DivAssign<f64> for Quantity

Source§

fn div_assign(&mut self, rhs: f64)

Performs the /= operation. Read more
Source§

impl DivAssign for Quantity

Source§

fn div_assign(&mut self, rhs: Self)

Performs the /= operation. Read more
Source§

impl From<AmountOfSubstance> for Quantity

Source§

fn from(quantity: AmountOfSubstance) -> Self

Converts to this type from the input type.
Source§

impl From<Angle> for Quantity

Source§

fn from(quantity: Angle) -> Self

Converts to this type from the input type.
Source§

impl From<Dimensionless> for Quantity

Source§

fn from(quantity: Dimensionless) -> Self

Converts to this type from the input type.
Source§

impl From<ElectricCurrent> for Quantity

Source§

fn from(quantity: ElectricCurrent) -> Self

Converts to this type from the input type.
Source§

impl From<Length> for Quantity

Source§

fn from(quantity: Length) -> Self

Converts to this type from the input type.
Source§

impl From<Luminance> for Quantity

Source§

fn from(quantity: Luminance) -> Self

Converts to this type from the input type.
Source§

impl From<Mass> for Quantity

Source§

fn from(quantity: Mass) -> Self

Converts to this type from the input type.
Source§

impl From<Quantities> for Quantity

Source§

fn from(value: Quantities) -> Self

Converts to this type from the input type.
Source§

impl From<Quantity> for AmountOfSubstance

Source§

fn from(quantity: Quantity) -> AmountOfSubstance

Converts to this type from the input type.
Source§

impl From<Quantity> for Angle

Source§

fn from(quantity: Quantity) -> Angle

Converts to this type from the input type.
Source§

impl From<Quantity> for Dimensionless

Source§

fn from(quantity: Quantity) -> Dimensionless

Converts to this type from the input type.
Source§

impl From<Quantity> for ElectricCurrent

Source§

fn from(quantity: Quantity) -> ElectricCurrent

Converts to this type from the input type.
Source§

impl From<Quantity> for Length

Source§

fn from(quantity: Quantity) -> Length

Converts to this type from the input type.
Source§

impl From<Quantity> for Luminance

Source§

fn from(quantity: Quantity) -> Luminance

Converts to this type from the input type.
Source§

impl From<Quantity> for Mass

Source§

fn from(quantity: Quantity) -> Mass

Converts to this type from the input type.
Source§

impl From<Quantity> for TemperatureInterval

Source§

fn from(quantity: Quantity) -> TemperatureInterval

Converts to this type from the input type.
Source§

impl From<Quantity> for Time

Source§

fn from(quantity: Quantity) -> Time

Converts to this type from the input type.
Source§

impl From<TemperatureInterval> for Quantity

Source§

fn from(quantity: TemperatureInterval) -> Self

Converts to this type from the input type.
Source§

impl From<Time> for Quantity

Source§

fn from(quantity: Time) -> Self

Converts to this type from the input type.
Source§

impl Mul<f64> for Quantity

Source§

type Output = Quantity

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: f64) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul for Quantity

Source§

type Output = Quantity

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Quantity) -> Self::Output

Performs the * operation. Read more
Source§

impl MulAssign<f64> for Quantity

Source§

fn mul_assign(&mut self, rhs: f64)

Performs the *= operation. Read more
Source§

impl MulAssign for Quantity

Source§

fn mul_assign(&mut self, rhs: Self)

Performs the *= operation. Read more
Source§

impl PartialEq<AmountOfSubstance> for Quantity

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Angle> for Quantity

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Dimensionless> for Quantity

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<ElectricCurrent> for Quantity

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Length> for Quantity

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Luminance> for Quantity

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Mass> for Quantity

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Quantity> for AmountOfSubstance

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Quantity> for Angle

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Quantity> for Dimensionless

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Quantity> for ElectricCurrent

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Quantity> for Length

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Quantity> for Luminance

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Quantity> for Mass

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Quantity> for TemperatureInterval

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Quantity> for Time

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<TemperatureInterval> for Quantity

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq<Time> for Quantity

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialEq for Quantity

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for Quantity

This only compares magnitudes…

Source§

fn partial_cmp(&self, other: &Quantity) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Sub<Quantity> for AmountOfSubstance

Source§

type Output = AmountOfSubstance

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Quantity) -> Self

Performs the - operation. Read more
Source§

impl Sub<Quantity> for Angle

Source§

type Output = Angle

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Quantity) -> Self

Performs the - operation. Read more
Source§

impl Sub<Quantity> for Dimensionless

Source§

type Output = Dimensionless

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Quantity) -> Self

Performs the - operation. Read more
Source§

impl Sub<Quantity> for ElectricCurrent

Source§

type Output = ElectricCurrent

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Quantity) -> Self

Performs the - operation. Read more
Source§

impl Sub<Quantity> for Length

Source§

type Output = Length

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Quantity) -> Self

Performs the - operation. Read more
Source§

impl Sub<Quantity> for Luminance

Source§

type Output = Luminance

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Quantity) -> Self

Performs the - operation. Read more
Source§

impl Sub<Quantity> for Mass

Source§

type Output = Mass

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Quantity) -> Self

Performs the - operation. Read more
Source§

impl Sub<Quantity> for TemperatureInterval

Source§

type Output = TemperatureInterval

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Quantity) -> Self

Performs the - operation. Read more
Source§

impl Sub<Quantity> for Time

Source§

type Output = Time

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Quantity) -> Self

Performs the - operation. Read more
Source§

impl Sub for Quantity

Source§

type Output = Quantity

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Quantity) -> Self::Output

Performs the - operation. Read more
Source§

impl SubAssign<Quantity> for AmountOfSubstance

Source§

fn sub_assign(&mut self, rhs: Quantity)

Performs the -= operation. Read more
Source§

impl SubAssign<Quantity> for Angle

Source§

fn sub_assign(&mut self, rhs: Quantity)

Performs the -= operation. Read more
Source§

impl SubAssign<Quantity> for Dimensionless

Source§

fn sub_assign(&mut self, rhs: Quantity)

Performs the -= operation. Read more
Source§

impl SubAssign<Quantity> for ElectricCurrent

Source§

fn sub_assign(&mut self, rhs: Quantity)

Performs the -= operation. Read more
Source§

impl SubAssign<Quantity> for Length

Source§

fn sub_assign(&mut self, rhs: Quantity)

Performs the -= operation. Read more
Source§

impl SubAssign<Quantity> for Luminance

Source§

fn sub_assign(&mut self, rhs: Quantity)

Performs the -= operation. Read more
Source§

impl SubAssign<Quantity> for Mass

Source§

fn sub_assign(&mut self, rhs: Quantity)

Performs the -= operation. Read more
Source§

impl SubAssign<Quantity> for TemperatureInterval

Source§

fn sub_assign(&mut self, rhs: Quantity)

Performs the -= operation. Read more
Source§

impl SubAssign<Quantity> for Time

Source§

fn sub_assign(&mut self, rhs: Quantity)

Performs the -= operation. Read more
Source§

impl SubAssign for Quantity

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
Source§

impl Copy for Quantity

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.