Struct quantity::Quantity

source ·
pub struct Quantity<F, U> { /* private fields */ }
Expand description

Implementations§

source§

impl<T> Quantity<T, SIUnit>

source

pub fn into_raw_parts(self) -> (T, [i8; 7])

Split an SI quantity into its value and unit vector.

source

pub fn from_raw_parts(value: T, unit: [i8; 7]) -> Self

Create an SI quantity from its value and unit vector.

source§

impl Quantity<f64, SIUnit>

source

pub fn to_latex(&self) -> String

source§

impl<F, U: Unit> Quantity<F, U>

§Methods for All Quantities

source

pub fn has_unit<F2>(&self, other: &Quantity<F2, U>) -> bool

Check if the quantity has the same unit as the argument.

§Example
let p = 5.0 * NEWTON/METER.powi(2);
assert!(p.has_unit(&BAR));
source

pub fn value(&self) -> Result<&F, QuantityError>

Return a reference to its value if the quantity is dimensionless.

§Example
let p1 = 5.0 * PASCAL;
let p2 = 2.5 * PASCAL;
let ratio = p1 / p2;
assert_relative_eq!(ratio.value()?, &2.0);
source

pub fn into_value(self) -> Result<F, QuantityError>

Converts to its value if the quantity is dimensionless.

§Example
let p1 = 5.0 * PASCAL;
let p2 = 2.5 * PASCAL;
let ratio = p1 / p2;
assert_relative_eq!(ratio.into_value()?, 2.0);
source

pub fn to_reduced<'a>( &'a self, reference: QuantityScalar<U> ) -> Result<F, QuantityError>
where &'a Self: Div<QuantityScalar<U>, Output = Self>,

Returns the value of self in a given unit if possible.

§Example
let p = 5.0 * BAR;
assert_relative_eq!(p.to_reduced(PASCAL)?, 500000.0);
source§

impl<U: Unit> Quantity<f64, U>

§Methods for Scalar Quantities

source

pub fn powi(&self, i: i32) -> Self

Calculate the integer power of self.

§Example
let x = 5.0 * METER;
assert_relative_eq!(x.powi(2), &(25.0 * METER * METER));
source

pub fn sqrt(&self) -> Result<Self, QuantityError>

Try to calculate the square root of self.

§Example
let x = 25.0 * METER * METER;
assert_relative_eq!(x.sqrt()?, &(5.0 * METER));
assert!(METER.sqrt().is_err());
source

pub fn cbrt(&self) -> Result<Self, QuantityError>

Try to calculate the cubic root of self.

§Example
let x = 125.0 * METER * METER * METER;
assert_relative_eq!(x.cbrt()?, &(5.0 * METER));
assert!(METER.cbrt().is_err());
source

pub fn root(&self, i: i32) -> Result<Self, QuantityError>

Try to calculate the integer root of self.

§Example
let x = 625.0 * METER * METER * METER * METER;
assert_relative_eq!(x.root(4)?, &(5.0 * METER));
assert!(METER.root(4).is_err());
source

pub fn max(&self, other: Self) -> Result<Self, QuantityError>
where U: PartialEq + Clone,

Return the maximum of self and other if they have the same unit.

§Example
let p1 = 110.0 * KILO * PASCAL;
let p2 = BAR;
assert_relative_eq!(p1.max(p2)?, &p1);
assert!(BAR.max(KELVIN).is_err());
source

pub fn min(&self, other: Self) -> Result<Self, QuantityError>
where U: PartialEq + Clone,

Return the minimum of self and other if they have the same unit.

§Example
let p1 = 110.0 * KILO * PASCAL;
let p2 = BAR;
assert_relative_eq!(p1.min(p2)?, &p2);
assert!(BAR.min(KELVIN).is_err());
source

pub fn abs(&self) -> Self
where U: Clone,

Return the absolute value of self.

§Example
let t = -50.0 * KELVIN;
assert_relative_eq!(t.abs(), &(50.0 * KELVIN));
source

pub fn signum(&self) -> f64

Returns a number that represents the sign of self.

  • 1.0 if the number is positive, +0.0 or INFINITY
  • -1.0 if the number is negative, -0.0 or NEG_INFINITY
  • NAN if the number is NAN
source

pub fn is_sign_positive(&self) -> bool

Returns true if self has a positive sign, including +0.0, NaNs with positive sign bit and positive infinity.

source

pub fn is_sign_negative(&self) -> bool

Returns true if self has a negative sign, including -0.0, NaNs with negative sign bit and negative infinity.

source

pub fn is_nan(&self) -> bool

Returns true if this value is NaN.

source§

impl<U: Unit, D: Dimension, S: Data<Elem = f64>> Quantity<ArrayBase<S, D>, U>

§Methods for n-Dimensional Array Quantities

source

pub fn sum(&self) -> QuantityScalar<U>

Return the sum of all elements in the array.

§Example
let x = arr1(&[1.5, 2.5]) * BAR;
assert_relative_eq!(x.sum(), &(4.0 * BAR));
source

pub fn len(&self) -> usize

Return the total number of elements in the array.

source

pub fn is_empty(&self) -> bool

Return whether the array has any elements

source

pub fn raw_dim(&self) -> D

Return the shape of the array as it’s stored in the array.

source

pub fn shape(&self) -> &[usize]

Return the shape of the array as a slice.

source

pub fn to_owned(&self) -> QuantityArray<U, D>

Return an uniquely owned copy of the array.

source

pub fn get<I: NdIndex<D>>(&self, index: I) -> QuantityScalar<U>

Return the element at index.

The Index trait can not be implemented, because a new instance has to be created, when indexing a quantity array. This serves as replacement for it.

source

pub fn try_set<I: NdIndex<D>>( &mut self, index: I, scalar: QuantityScalar<U> ) -> Result<(), QuantityError>
where S: DataMut,

Set the element at index to scalar if scalar has the same unit as self.

source

pub fn index_axis( &self, axis: Axis, index: usize ) -> Quantity<ArrayView<'_, f64, D::Smaller>, U>
where D: RemoveAxis,

Returns a view restricted to index along the axis, with the axis removed.

source

pub fn insert_axis(self, axis: Axis) -> Quantity<ArrayBase<S, D::Larger>, U>

Insert new array axis at axis and return the result.

source

pub fn sum_axis(&self, axis: Axis) -> Quantity<Array<f64, D::Smaller>, U>
where D: RemoveAxis,

Return sum along axis.

source

pub fn to_vec(&self) -> Vec<QuantityScalar<U>>

Return a vector of scalar quantities for each element of self.

source

pub fn from_shape_fn<Sh, F>(shape: Sh, f: F) -> QuantityArray<U, D>
where Sh: ShapeBuilder<Dim = D>, F: FnMut(D::Pattern) -> QuantityScalar<U>,

Create an array with values created by the function f.

source

pub fn powi(&self, i: i32) -> QuantityArray<U, D>

Calculate the integer power of self.

§Example
let x = arr1(&[3.0, 5.0]) * METER;
assert_relative_eq!(x.powi(2), &(arr1(&[9.0, 25.0]) * METER * METER));
source

pub fn sqrt(&self) -> Result<QuantityArray<U, D>, QuantityError>

Try to calculate the square root of self.

§Example
let x = arr1(&[9.0, 25.0]) * METER * METER;
assert_relative_eq!(x.sqrt()?, &(arr1(&[3.0, 5.0]) * METER));
source

pub fn cbrt(&self) -> Result<QuantityArray<U, D>, QuantityError>

Try to calculate the cubic root of self.

§Example
let x = arr1(&[27.0, 125.0]) * METER * METER * METER;
assert_relative_eq!(x.cbrt()?, &(arr1(&[3.0, 5.0]) * METER));
source

pub fn root(&self, i: i32) -> Result<QuantityArray<U, D>, QuantityError>

Try to calculate the integer root of self.

§Example
let x = arr1(&[81.0, 625.0]) * METER * METER * METER * METER;
assert_relative_eq!(x.root(4)?, &(arr1(&[3.0, 5.0]) * METER));
source§

impl<U: Unit> Quantity<ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>, U>

§Methods for 1-Dimensional Array Quantities

source

pub fn linspace( start: QuantityScalar<U>, end: QuantityScalar<U>, n: usize ) -> Result<Self, QuantityError>

Create a one-dimensional array with n evenly spaced elements from start to end (inclusive) if start and end have the same unit.

§Example
let x = SIArray1::linspace(1.0 * METER, 3.0 * METER, 5)?;
assert_relative_eq!(x, &(arr1(&[1.0, 1.5, 2.0, 2.5, 3.0]) * METER));
source

pub fn logspace( start: QuantityScalar<U>, end: QuantityScalar<U>, n: usize ) -> Result<Self, QuantityError>

Create a one-dimensional array with n logarithmically spaced elements from start to end (inclusive) if start and end have the same unit.

§Example
let x = SIArray1::logspace(1.0 * METER, 16.0 * METER, 5)?;
assert_relative_eq!(x, &(arr1(&[1.0, 2.0, 4.0, 8.0, 16.0]) * METER));
source

pub fn from_vec(vec: Vec<QuantityScalar<U>>) -> Self

Create a one-dimensional array from a vector of scalar quantities.

Trait Implementations§

source§

impl<F: AbsDiffEq, U: PartialEq + Display> AbsDiffEq for Quantity<F, U>

§

type Epsilon = <F as AbsDiffEq>::Epsilon

Used for specifying relative comparisons.
source§

fn default_epsilon() -> Self::Epsilon

The default tolerance to use when testing values that are close together. Read more
source§

fn abs_diff_eq(&self, other: &Self, epsilon: Self::Epsilon) -> bool

A test for equality that uses the absolute difference to compute the approximate equality of two numbers.
source§

fn abs_diff_ne(&self, other: &Rhs, epsilon: Self::Epsilon) -> bool

The inverse of AbsDiffEq::abs_diff_eq.
source§

impl<'a, 'b, F, F2, U> Add<&'b Quantity<F2, U>> for &'a Quantity<F, U>

§

type Output = Quantity<<&'a F as Add<&'b F2>>::Output, U>

The resulting type after applying the + operator.
source§

fn add(self, other: &'b Quantity<F2, U>) -> Self::Output

Performs the + operation. Read more
source§

impl<'a, F, F2, U> Add<&'a Quantity<F2, U>> for Quantity<F, U>
where F: Add<&'a F2>, U: PartialEq + Display,

§

type Output = Quantity<<F as Add<&'a F2>>::Output, U>

The resulting type after applying the + operator.
source§

fn add(self, other: &'a Quantity<F2, U>) -> Self::Output

Performs the + operation. Read more
source§

impl<'a, F, F2, U> Add<Quantity<F2, U>> for &'a Quantity<F, U>
where &'a F: Add<F2>, U: Copy + PartialEq + Display,

§

type Output = Quantity<<&'a F as Add<F2>>::Output, U>

The resulting type after applying the + operator.
source§

fn add(self, other: Quantity<F2, U>) -> Self::Output

Performs the + operation. Read more
source§

impl<F, F2, U> Add<Quantity<F2, U>> for Quantity<F, U>
where F: Add<F2>, U: PartialEq + Display,

§

type Output = Quantity<<F as Add<F2>>::Output, U>

The resulting type after applying the + operator.
source§

fn add(self, other: Quantity<F2, U>) -> Self::Output

Performs the + operation. Read more
source§

impl<'a, F, F2, U> AddAssign<&'a Quantity<F2, U>> for Quantity<F, U>

source§

fn add_assign(&mut self, other: &'a Quantity<F2, U>)

Performs the += operation. Read more
source§

impl<F, F2, U> AddAssign<Quantity<F2, U>> for Quantity<F, U>
where F: AddAssign<F2>, U: PartialEq + Display,

source§

fn add_assign(&mut self, other: Quantity<F2, U>)

Performs the += operation. Read more
source§

impl<F: Clone, U: Clone> Clone for Quantity<F, U>

source§

fn clone(&self) -> Quantity<F, U>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<F: Debug, U: Debug> Debug for Quantity<F, U>

source§

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

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

impl<F: Default, U: Default> Default for Quantity<F, U>

source§

fn default() -> Quantity<F, U>

Returns the “default value” for a type. Read more
source§

impl<'de, F, U> Deserialize<'de> for Quantity<F, U>
where F: Deserialize<'de>, U: Deserialize<'de>,

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<'a, F, U, S: RawData, D> Div<&'a ArrayBase<S, D>> for Quantity<F, U>
where F: Div<&'a ArrayBase<S, D>>,

§

type Output = Quantity<<F as Div<&'a ArrayBase<S, D>>>::Output, U>

The resulting type after applying the / operator.
source§

fn div(self, other: &'a ArrayBase<S, D>) -> Self::Output

Performs the / operation. Read more
source§

impl<'a, 'b, F, F2, U> Div<&'b Quantity<F2, U>> for &'a Quantity<F, U>
where &'a F: Div<&'b F2>, U: Div<Output = U> + Copy,

§

type Output = Quantity<<&'a F as Div<&'b F2>>::Output, U>

The resulting type after applying the / operator.
source§

fn div(self, other: &'b Quantity<F2, U>) -> Self::Output

Performs the / operation. Read more
source§

impl<'a, F, F2, U> Div<&'a Quantity<F2, U>> for Quantity<F, U>
where F: Div<&'a F2>, U: Div<Output = U> + Copy,

§

type Output = Quantity<<F as Div<&'a F2>>::Output, U>

The resulting type after applying the / operator.
source§

fn div(self, other: &'a Quantity<F2, U>) -> Self::Output

Performs the / operation. Read more
source§

impl<F, U, S: RawData, D> Div<ArrayBase<S, D>> for Quantity<F, U>
where F: Div<ArrayBase<S, D>>,

§

type Output = Quantity<<F as Div<ArrayBase<S, D>>>::Output, U>

The resulting type after applying the / operator.
source§

fn div(self, other: ArrayBase<S, D>) -> Self::Output

Performs the / operation. Read more
source§

impl<'a, F, U, S: RawData, D> Div<Quantity<F, U>> for &'a ArrayBase<S, D>
where &'a ArrayBase<S, D>: Div<F>, U: Unit,

§

type Output = Quantity<<&'a ArrayBase<S, D> as Div<F>>::Output, U>

The resulting type after applying the / operator.
source§

fn div(self, other: Quantity<F, U>) -> Self::Output

Performs the / operation. Read more
source§

impl<F, U, S: RawData, D> Div<Quantity<F, U>> for ArrayBase<S, D>
where ArrayBase<S, D>: Div<F>, U: Unit,

§

type Output = Quantity<<ArrayBase<S, D> as Div<F>>::Output, U>

The resulting type after applying the / operator.
source§

fn div(self, other: Quantity<F, U>) -> Self::Output

Performs the / operation. Read more
source§

impl<F, U> Div<Quantity<F, U>> for f64
where f64: Div<F>, U: Unit,

§

type Output = Quantity<<f64 as Div<F>>::Output, U>

The resulting type after applying the / operator.
source§

fn div(self, other: Quantity<F, U>) -> Self::Output

Performs the / operation. Read more
source§

impl<'a, F, F2, U> Div<Quantity<F2, U>> for &'a Quantity<F, U>
where &'a F: Div<F2>, U: Div<Output = U> + Copy,

§

type Output = Quantity<<&'a F as Div<F2>>::Output, U>

The resulting type after applying the / operator.
source§

fn div(self, other: Quantity<F2, U>) -> Self::Output

Performs the / operation. Read more
source§

impl<F, F2, U> Div<Quantity<F2, U>> for Quantity<F, U>
where F: Div<F2>, U: Div<Output = U>,

§

type Output = Quantity<<F as Div<F2>>::Output, U>

The resulting type after applying the / operator.
source§

fn div(self, other: Quantity<F2, U>) -> Self::Output

Performs the / operation. Read more
source§

impl<'a, F, U> Div<f64> for &'a Quantity<F, U>
where &'a F: Div<f64>, U: Copy,

§

type Output = Quantity<<&'a F as Div<f64>>::Output, U>

The resulting type after applying the / operator.
source§

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

Performs the / operation. Read more
source§

impl<F, U> Div<f64> for Quantity<F, U>
where F: Div<f64>,

§

type Output = Quantity<<F as Div<f64>>::Output, U>

The resulting type after applying the / operator.
source§

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

Performs the / operation. Read more
source§

impl<'a, F, F2, U> DivAssign<&'a Quantity<F2, U>> for Quantity<F, U>
where F: DivAssign<&'a F2>, U: DivAssign + Copy,

source§

fn div_assign(&mut self, other: &'a Quantity<F2, U>)

Performs the /= operation. Read more
source§

impl<F, F2, U> DivAssign<Quantity<F2, U>> for Quantity<F, U>
where F: DivAssign<F2>, U: DivAssign,

source§

fn div_assign(&mut self, other: Quantity<F2, U>)

Performs the /= operation. Read more
source§

impl<F, U: Unit> From<F> for Quantity<F, U>

source§

fn from(value: F) -> Self

Converts to this type from the input type.
source§

impl<U: Unit> FromIterator<Quantity<f64, U>> for QuantityArray1<U>

source§

fn from_iter<I>(iter: I) -> Self
where I: IntoIterator<Item = QuantityScalar<U>>,

Creates a value from an iterator. Read more
source§

impl<'a, F, U: Copy> IntoIterator for &'a Quantity<F, U>
where &'a F: IntoIterator<Item = &'a f64>,

§

type Item = Quantity<f64, U>

The type of the elements being iterated over.
§

type IntoIter = QuantityIter<<&'a F as IntoIterator>::IntoIter, U>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<'a, F, U, S: RawData, D> Mul<&'a ArrayBase<S, D>> for Quantity<F, U>
where F: Mul<&'a ArrayBase<S, D>>,

§

type Output = Quantity<<F as Mul<&'a ArrayBase<S, D>>>::Output, U>

The resulting type after applying the * operator.
source§

fn mul(self, other: &'a ArrayBase<S, D>) -> Self::Output

Performs the * operation. Read more
source§

impl<'a, 'b, F, F2, U> Mul<&'b Quantity<F2, U>> for &'a Quantity<F, U>
where &'a F: Mul<&'b F2>, U: Mul<Output = U> + Copy,

§

type Output = Quantity<<&'a F as Mul<&'b F2>>::Output, U>

The resulting type after applying the * operator.
source§

fn mul(self, other: &'b Quantity<F2, U>) -> Self::Output

Performs the * operation. Read more
source§

impl<'a, F, F2, U> Mul<&'a Quantity<F2, U>> for Quantity<F, U>
where F: Mul<&'a F2>, U: Mul<Output = U> + Copy,

§

type Output = Quantity<<F as Mul<&'a F2>>::Output, U>

The resulting type after applying the * operator.
source§

fn mul(self, other: &'a Quantity<F2, U>) -> Self::Output

Performs the * operation. Read more
source§

impl<F, U, S: RawData, D> Mul<ArrayBase<S, D>> for Quantity<F, U>
where F: Mul<ArrayBase<S, D>>,

§

type Output = Quantity<<F as Mul<ArrayBase<S, D>>>::Output, U>

The resulting type after applying the * operator.
source§

fn mul(self, other: ArrayBase<S, D>) -> Self::Output

Performs the * operation. Read more
source§

impl<'a, F, U, S: RawData, D> Mul<Quantity<F, U>> for &'a ArrayBase<S, D>
where &'a ArrayBase<S, D>: Mul<F>, U: Unit,

§

type Output = Quantity<<&'a ArrayBase<S, D> as Mul<F>>::Output, U>

The resulting type after applying the * operator.
source§

fn mul(self, other: Quantity<F, U>) -> Self::Output

Performs the * operation. Read more
source§

impl<F, U, S: RawData, D> Mul<Quantity<F, U>> for ArrayBase<S, D>
where ArrayBase<S, D>: Mul<F>, U: Unit,

§

type Output = Quantity<<ArrayBase<S, D> as Mul<F>>::Output, U>

The resulting type after applying the * operator.
source§

fn mul(self, other: Quantity<F, U>) -> Self::Output

Performs the * operation. Read more
source§

impl<F, U> Mul<Quantity<F, U>> for f64
where f64: Mul<F>, U: Unit,

§

type Output = Quantity<<f64 as Mul<F>>::Output, U>

The resulting type after applying the * operator.
source§

fn mul(self, other: Quantity<F, U>) -> Self::Output

Performs the * operation. Read more
source§

impl<'a, F, F2, U> Mul<Quantity<F2, U>> for &'a Quantity<F, U>
where &'a F: Mul<F2>, U: Mul<Output = U> + Copy,

§

type Output = Quantity<<&'a F as Mul<F2>>::Output, U>

The resulting type after applying the * operator.
source§

fn mul(self, other: Quantity<F2, U>) -> Self::Output

Performs the * operation. Read more
source§

impl<F, F2, U> Mul<Quantity<F2, U>> for Quantity<F, U>
where F: Mul<F2>, U: Mul<Output = U>,

§

type Output = Quantity<<F as Mul<F2>>::Output, U>

The resulting type after applying the * operator.
source§

fn mul(self, other: Quantity<F2, U>) -> Self::Output

Performs the * operation. Read more
source§

impl<'a, F, U> Mul<f64> for &'a Quantity<F, U>
where &'a F: Mul<f64>, U: Copy,

§

type Output = Quantity<<&'a F as Mul<f64>>::Output, U>

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl<F, U> Mul<f64> for Quantity<F, U>
where F: Mul<f64>,

§

type Output = Quantity<<F as Mul<f64>>::Output, U>

The resulting type after applying the * operator.
source§

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

Performs the * operation. Read more
source§

impl<'a, F, F2, U> MulAssign<&'a Quantity<F2, U>> for Quantity<F, U>
where F: MulAssign<&'a F2>, U: MulAssign + Copy,

source§

fn mul_assign(&mut self, other: &'a Quantity<F2, U>)

Performs the *= operation. Read more
source§

impl<F, F2, U> MulAssign<Quantity<F2, U>> for Quantity<F, U>
where F: MulAssign<F2>, U: MulAssign,

source§

fn mul_assign(&mut self, other: Quantity<F2, U>)

Performs the *= operation. Read more
source§

impl<'a, F, U> Neg for &'a Quantity<F, U>
where &'a F: Neg, U: Copy,

§

type Output = Quantity<<&'a F as Neg>::Output, U>

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl<F: Neg, U> Neg for Quantity<F, U>

§

type Output = Quantity<<F as Neg>::Output, U>

The resulting type after applying the - operator.
source§

fn neg(self) -> Self::Output

Performs the unary - operation. Read more
source§

impl<F: PartialEq, U: PartialEq + Display> PartialEq for Quantity<F, U>

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<F: PartialOrd, U: PartialEq + Display> PartialOrd for Quantity<F, U>

source§

fn partial_cmp(&self, other: &Self) -> 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

This method 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

This method 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

This method 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

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<F: RelativeEq, U: PartialEq + Display> RelativeEq for Quantity<F, U>

source§

fn default_max_relative() -> Self::Epsilon

The default relative tolerance for testing values that are far-apart. Read more
source§

fn relative_eq( &self, other: &Self, epsilon: Self::Epsilon, max_relative: Self::Epsilon ) -> bool

A test for equality that uses a relative comparison if the values are far apart.
source§

fn relative_ne( &self, other: &Rhs, epsilon: Self::Epsilon, max_relative: Self::Epsilon ) -> bool

The inverse of RelativeEq::relative_eq.
source§

impl<F, U> Serialize for Quantity<F, U>
where F: Serialize, U: Serialize,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<'a, 'b, F, F2, U> Sub<&'b Quantity<F2, U>> for &'a Quantity<F, U>

§

type Output = Quantity<<&'a F as Sub<&'b F2>>::Output, U>

The resulting type after applying the - operator.
source§

fn sub(self, other: &'b Quantity<F2, U>) -> Self::Output

Performs the - operation. Read more
source§

impl<'a, F, F2, U> Sub<&'a Quantity<F2, U>> for Quantity<F, U>
where F: Sub<&'a F2>, U: PartialEq + Display,

§

type Output = Quantity<<F as Sub<&'a F2>>::Output, U>

The resulting type after applying the - operator.
source§

fn sub(self, other: &'a Quantity<F2, U>) -> Self::Output

Performs the - operation. Read more
source§

impl<'a, F, F2, U> Sub<Quantity<F2, U>> for &'a Quantity<F, U>
where &'a F: Sub<F2>, U: Copy + PartialEq + Display,

§

type Output = Quantity<<&'a F as Sub<F2>>::Output, U>

The resulting type after applying the - operator.
source§

fn sub(self, other: Quantity<F2, U>) -> Self::Output

Performs the - operation. Read more
source§

impl<F, F2, U> Sub<Quantity<F2, U>> for Quantity<F, U>
where F: Sub<F2>, U: PartialEq + Display,

§

type Output = Quantity<<F as Sub<F2>>::Output, U>

The resulting type after applying the - operator.
source§

fn sub(self, other: Quantity<F2, U>) -> Self::Output

Performs the - operation. Read more
source§

impl<'a, F, F2, U> SubAssign<&'a Quantity<F2, U>> for Quantity<F, U>

source§

fn sub_assign(&mut self, other: &'a Quantity<F2, U>)

Performs the -= operation. Read more
source§

impl<F, F2, U> SubAssign<Quantity<F2, U>> for Quantity<F, U>
where F: SubAssign<F2>, U: PartialEq + Display,

source§

fn sub_assign(&mut self, other: Quantity<F2, U>)

Performs the -= operation. Read more
source§

impl<F: Copy, U: Copy> Copy for Quantity<F, U>

Auto Trait Implementations§

§

impl<F, U> Freeze for Quantity<F, U>
where F: Freeze, U: Freeze,

§

impl<F, U> RefUnwindSafe for Quantity<F, U>

§

impl<F, U> Send for Quantity<F, U>
where F: Send, U: Send,

§

impl<F, U> Sync for Quantity<F, U>
where F: Sync, U: Sync,

§

impl<F, U> Unpin for Quantity<F, U>
where F: Unpin, U: Unpin,

§

impl<F, U> UnwindSafe for Quantity<F, U>
where F: UnwindSafe, U: UnwindSafe,

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> From<!> for T

source§

fn from(t: !) -> T

Converts to this type from the input type.
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,

§

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§

default 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>,

§

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>,

§

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.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,