Struct UnitSimple

Source
pub struct UnitSimple<S: MS> {
    pub ratio: S::N,
    pub offset: S::N,
}
Expand description

A Simple Unit in a given MeasureSystem

The equations for Unit are as follows:

self.to_base = (val + self.offset) * self.ratio

self.to_self = (val / self.ratio) - self.offset

If greater flexibility is required, please see `UnitTrait

Fields§

§ratio: S::N§offset: S::N

Trait Implementations§

Source§

impl<S: MS> Debug for UnitSimple<S>

Source§

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

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

impl<S: PartialEq + MS> PartialEq for UnitSimple<S>
where S::N: PartialEq,

Source§

fn eq(&self, other: &UnitSimple<S>) -> bool

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

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<S: MS> UnitTrait for UnitSimple<S>

Source§

type System = S

Source§

fn from(&self, val: S::N) -> Measure<S>

Generate a new Measure from this unit and value
Source§

fn to_base(&self, val: S::N) -> S::N

Convert the given value as this unit into the base unit Read more
Source§

fn to_self(&self, val: S::N) -> S::N

Convert the value as the base unit into this unit Read more
Source§

impl<S: MS> StructuralPartialEq for UnitSimple<S>

Auto Trait Implementations§

§

impl<S> Freeze for UnitSimple<S>
where <S as MeasureSystem>::N: Freeze,

§

impl<S> RefUnwindSafe for UnitSimple<S>
where <S as MeasureSystem>::N: RefUnwindSafe,

§

impl<S> Send for UnitSimple<S>
where <S as MeasureSystem>::N: Send,

§

impl<S> Sync for UnitSimple<S>
where <S as MeasureSystem>::N: Sync,

§

impl<S> Unpin for UnitSimple<S>
where <S as MeasureSystem>::N: Unpin,

§

impl<S> UnwindSafe for UnitSimple<S>
where <S as MeasureSystem>::N: 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<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, 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.