Skip to main content

DivExpression

Struct DivExpression 

Source
pub struct DivExpression<L, R> {
    pub numerator: L,
    pub denominator: R,
}
Expand description

An expression representing deferred division.

Evaluations are deferred to preserve precision, scaling only when converted to a target resolution or assigned to a Fixed variable.

Fields§

§numerator: L

The numerator of the division expression.

§denominator: R

The denominator of the division expression.

Implementations§

Source§

impl<IL, const FL: usize, IR, const FR: usize> DivExpression<FastFixed<IL, FL>, FastFixed<IR, FR>>

Source

pub fn evaluate<I, const TARGET_FRAC: usize>(self) -> FastFixed<I, TARGET_FRAC>
where FastFixed<I, TARGET_FRAC>: From<Self>,

Evaluates the deferred division into a FastFixed value of the target format.

§Panics

Panics if the denominator is zero.

Trait Implementations§

Source§

impl<I, const TARGET_FRAC: usize, IL, const FL: usize, IR, const FR: usize> From<DivExpression<FastFixed<IL, FL>, FastFixed<IR, FR>>> for FastFixed<I, TARGET_FRAC>
where I: Bounded + NumCast + Copy + FastInt, IL: Zero + PartialOrd + NumCast + Copy, IR: Zero + PartialOrd + NumCast + Copy,

Source§

fn from(expr: DivExpression<FastFixed<IL, FL>, FastFixed<IR, FR>>) -> Self

Converts to this type from the input type.
Source§

impl<I, const TARGET_FRAC: usize, IL, const FL: usize, IR, const FR: usize> From<DivExpression<Fixed<IL, FL>, Fixed<IR, FR>>> for Fixed<I, TARGET_FRAC>
where I: Bounded + TryFrom<i128> + Copy, IL: Into<i128> + Copy, IR: Into<i128> + Copy,

Source§

fn from(expr: DivExpression<Fixed<IL, FL>, Fixed<IR, FR>>) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<L, R> Freeze for DivExpression<L, R>
where L: Freeze, R: Freeze,

§

impl<L, R> RefUnwindSafe for DivExpression<L, R>
where L: RefUnwindSafe, R: RefUnwindSafe,

§

impl<L, R> Send for DivExpression<L, R>
where L: Send, R: Send,

§

impl<L, R> Sync for DivExpression<L, R>
where L: Sync, R: Sync,

§

impl<L, R> Unpin for DivExpression<L, R>
where L: Unpin, R: Unpin,

§

impl<L, R> UnsafeUnpin for DivExpression<L, R>
where L: UnsafeUnpin, R: UnsafeUnpin,

§

impl<L, R> UnwindSafe for DivExpression<L, R>
where L: UnwindSafe, R: UnwindSafe,

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
§

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

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

Performs the conversion.