Struct Quantity
pub struct Quantity<S, D>{ /* private fields */ }Description
Statically dimensioned quantity — the only representation of physical values inside the platform (rule 1).
Implementations§
§impl<S, D> Quantity<S, D>where
S: Scalar,
D: Dimension,
impl<S, D> Quantity<S, D>where
S: Scalar,
D: Dimension,
pub const fn from_scalar(value: S) -> Quantity<S, D>
pub const fn from_scalar(value: S) -> Quantity<S, D>
Wrap an explicitly typed scalar. Prefer Quantity::new for the
default f64 representation. External data goes through
DynQuantity::checked_cast instead.
§impl<D> Quantity<f64, D>where
D: Dimension,
impl<D> Quantity<f64, D>where
D: Dimension,
pub const fn new(value: f64) -> Quantity<f64, D>
pub const fn new(value: f64) -> Quantity<f64, D>
Wrap an f64 literal or trusted numerical value in a static
dimension. This is intentionally the unqualified constructor so
aliases such as Velocity::new(3.0) select the default scalar
without an inference annotation.
pub fn into_dyn(self) -> DynQuantity
pub fn into_dyn(self) -> DynQuantity
Demote into the dynamic layer. Always safe (rule 3).
§impl<D> Quantity<f32, D>where
D: Dimension,
impl<D> Quantity<f32, D>where
D: Dimension,
Trait Implementations§
§impl<S, D> Add for Quantity<S, D>where
S: Scalar,
D: Dimension,
impl<S, D> Add for Quantity<S, D>where
S: Scalar,
D: Dimension,
§impl<S, D> Clone for Quantity<S, D>where
S: Scalar,
D: Dimension,
impl<S, D> Clone for Quantity<S, D>where
S: Scalar,
D: Dimension,
§impl<S, D> Debug for Quantity<S, D>where
S: Scalar,
D: Dimension,
impl<S, D> Debug for Quantity<S, D>where
S: Scalar,
D: Dimension,
§impl<S, D> Div<S> for Quantity<S, D>where
S: Scalar,
D: Dimension,
impl<S, D> Div<S> for Quantity<S, D>where
S: Scalar,
D: Dimension,
§impl<D> From<Quantity<f64, D>> for DynQuantitywhere
D: Dimension,
impl<D> From<Quantity<f64, D>> for DynQuantitywhere
D: Dimension,
§fn from(q: Quantity<f64, D>) -> DynQuantity
fn from(q: Quantity<f64, D>) -> DynQuantity
Converts to this type from the input type.
§impl<S, D> Mul<S> for Quantity<S, D>where
S: Scalar,
D: Dimension,
Scaling by a bare scalar preserves the dimension.
impl<S, D> Mul<S> for Quantity<S, D>where
S: Scalar,
D: Dimension,
Scaling by a bare scalar preserves the dimension.
§impl<S, D> Neg for Quantity<S, D>where
S: Scalar,
D: Dimension,
impl<S, D> Neg for Quantity<S, D>where
S: Scalar,
D: Dimension,
§impl<S, D> PartialEq for Quantity<S, D>where
S: Scalar,
D: Dimension,
impl<S, D> PartialEq for Quantity<S, D>where
S: Scalar,
D: Dimension,
§fn eq(&self, other: &Quantity<S, D>) -> bool
fn eq(&self, other: &Quantity<S, D>) -> bool
Tests for
self and other values to be equal, and is used by ==.§impl<S, D> PartialOrd for Quantity<S, D>where
S: Scalar,
D: Dimension,
impl<S, D> PartialOrd for Quantity<S, D>where
S: Scalar,
D: Dimension,
§fn partial_cmp(&self, other: &Quantity<S, D>) -> Option<Ordering>
fn partial_cmp(&self, other: &Quantity<S, D>) -> Option<Ordering>
1.0.0 (const: unstable) · Source§fn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
1.0.0 (const: unstable) · Source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
1.0.0 (const: unstable) · Source§fn gt(&self, other: &Rhs) -> bool
fn gt(&self, other: &Rhs) -> bool
§impl<S, D> Sub for Quantity<S, D>where
S: Scalar,
D: Dimension,
impl<S, D> Sub for Quantity<S, D>where
S: Scalar,
D: Dimension,
impl<S, D> Copy for Quantity<S, D>
Auto Trait Implementations§
impl<S, D> Freeze for Quantity<S, D>where
S: Freeze,
impl<S, D> RefUnwindSafe for Quantity<S, D>where
S: RefUnwindSafe,
impl<S, D> Send for Quantity<S, D>where
S: Send,
impl<S, D> Sync for Quantity<S, D>where
S: Sync,
impl<S, D> Unpin for Quantity<S, D>where
S: Unpin,
impl<S, D> UnsafeUnpin for Quantity<S, D>where
S: UnsafeUnpin,
impl<S, D> UnwindSafe for Quantity<S, D>where
S: UnwindSafe,
Blanket Implementations§
Source§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
impl<Src, Scheme> ApproxFrom<Src, Scheme> for Srcwhere
Scheme: ApproxScheme,
Signature links:§
§fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
fn approx_from(src: Src) -> Result<Src, <Src as ApproxFrom<Src, Scheme>>::Err>
Convert the given value into an approximately equivalent representation.
§impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
impl<Dst, Src, Scheme> ApproxInto<Dst, Scheme> for Srcwhere
Dst: ApproxFrom<Src, Scheme>,
Scheme: ApproxScheme,
Signature links:§
§type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
type Err = <Dst as ApproxFrom<Src, Scheme>>::Err
Signature links:§
The error type produced by a failed conversion.
§fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
fn approx_into(self) -> Result<Dst, <Src as ApproxInto<Dst, Scheme>>::Err>
Convert the subject into an approximately equivalent representation.
Source§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T, Dst> ConvAsUtil<Dst> for T
impl<T, Dst> ConvAsUtil<Dst> for T
Signature links:§
§fn approx(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
fn approx(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
Approximate the subject with the default scheme.
§impl<T> ConvUtil for T
impl<T> ConvUtil for T
Signature links:§
§fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
fn approx_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst>,
Approximate the subject to a given type with the default scheme.
§fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst, Scheme>,
Scheme: ApproxScheme,
fn approx_as_by<Dst, Scheme>(self) -> Result<Dst, Self::Err>where
Self: Sized + ApproxInto<Dst, Scheme>,
Scheme: ApproxScheme,
Approximate the subject to a given type with a specific scheme.
§fn into_as<Dst>(self) -> Dstwhere
Self: Sized + Into<Dst>,
fn into_as<Dst>(self) -> Dstwhere
Self: Sized + Into<Dst>,
Convert the subject to a given type.
§fn try_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + TryInto<Dst>,
fn try_as<Dst>(self) -> Result<Dst, Self::Err>where
Self: Sized + TryInto<Dst>,
Attempt to convert the subject to a given type.
§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> Twhere
Self: Distribution<T>,
Source§impl<T> From<T> for T
impl<T> From<T> for T
Source§impl<T, U> Into<U> for Twhere
U: From<T>,
impl<T, U> Into<U> for Twhere
U: From<T>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>where
F: FnOnce(&Self) -> bool,
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>where
F: FnOnce(&Self) -> bool,
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
Signature links:§
Source§impl<T> Same for T
impl<T> Same for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Signature links:§
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Signature links:§
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.Source§impl<T> ToOwned for Twhere
T: Clone,
impl<T> ToOwned for Twhere
T: Clone,
§impl<Src> TryFrom<Src> for Src
impl<Src> TryFrom<Src> for Src
Signature links:§
Source§impl<T, U> TryFrom<U> for Twhere
U: Into<T>,
impl<T, U> TryFrom<U> for Twhere
U: Into<T>,
§impl<Src, Dst> TryInto<Dst> for Srcwhere
Dst: TryFrom<Src>,
impl<Src, Dst> TryInto<Dst> for Srcwhere
Dst: TryFrom<Src>,
Signature links:§
Source§impl<T, U> TryInto<U> for Twhere
U: TryFrom<T>,
impl<T, U> TryInto<U> for Twhere
U: TryFrom<T>,
§impl<Src> ValueFrom<Src> for Src
impl<Src> ValueFrom<Src> for Src
Signature links:§
§fn value_from(src: Src) -> Result<Src, <Src as ValueFrom<Src>>::Err>
fn value_from(src: Src) -> Result<Src, <Src as ValueFrom<Src>>::Err>
Convert the given value into an exactly equivalent representation.
§impl<Src, Dst> ValueInto<Dst> for Srcwhere
Dst: ValueFrom<Src>,
impl<Src, Dst> ValueInto<Dst> for Srcwhere
Dst: ValueFrom<Src>,
Signature links:§
§type Err = <Dst as ValueFrom<Src>>::Err
type Err = <Dst as ValueFrom<Src>>::Err
Signature links:§
The error type produced by a failed conversion.
§fn value_into(self) -> Result<Dst, <Src as ValueInto<Dst>>::Err>
fn value_into(self) -> Result<Dst, <Src as ValueInto<Dst>>::Err>
Convert the subject into an exactly equivalent representation.