If

Struct If 

Source
pub struct If<C: Moment<Value = bool>, T: Moment, F: Moment> { /* private fields */ }
Expand description

A conditional calculation.

This struct allows you to branch calculations based on a condition. Both sides are still optimized, but only one side will be fully resolved.

Implementations§

Source§

impl<C: Moment<Value = bool>, T: Moment, F: Moment> If<C, T, F>

Source

pub fn new(condition: C, then: T, otherwise: F) -> Self

Create a new If struct.

This will branch the calculation based on the condition. If the condition is true, the then calculation will be resolved. Otherwise, the otherwise calculation will be resolved.

Source

pub async fn to_then(self) -> Option<T>

Tries to get the then calculation.

Source

pub async fn to_otherwise(self) -> Option<F>

Tries to get the otherwise calculation.

Trait Implementations§

Source§

impl<C, T, F, R, TO, FO> Add<R> for If<C, T, F>
where C: Moment<Value = bool>, T: Moment, F: Moment, R: Moment, TO: Moment, FO: Moment, T::Value: Add<R::Value, Output = TO>, F::Value: Add<R::Value, Output = FO>,

Source§

type Output = If<C, Add<T, R, TO>, Add<F, R, FO>>

The resulting type after applying the + operator.
Source§

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

Performs the + operation. Read more
Source§

impl<C: Clone + Moment<Value = bool>, T: Clone + Moment, F: Clone + Moment> Clone for If<C, T, F>

Source§

fn clone(&self) -> If<C, T, F>

Returns a duplicate 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<C, T, F, R, TO, FO> Div<R> for If<C, T, F>
where C: Moment<Value = bool>, T: Moment, F: Moment, R: Moment, TO: Moment, FO: Moment, T::Value: Div<R::Value, Output = TO>, F::Value: Div<R::Value, Output = FO>,

Source§

type Output = If<C, Div<T, R, TO>, Div<F, R, FO>>

The resulting type after applying the / operator.
Source§

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

Performs the / operation. Read more
Source§

impl<C, T, F> Moment for If<C, T, F>
where C: Moment<Value = bool>, T: Moment, F: Moment,

Source§

type Value = If<C, <T as Moment>::Value, <F as Moment>::Value>

The type of value that this Moment resolves to. Read more
Source§

fn resolve<'async_trait>( self, ) -> Pin<Box<dyn Future<Output = Self::Value> + Send + 'async_trait>>
where Self: 'async_trait,

Resolve this Moment into its value. Read more
Source§

impl<C, T, F, R, TO, FO> Mul<R> for If<C, T, F>
where C: Moment<Value = bool>, T: Moment, F: Moment, R: Moment, TO: Moment, FO: Moment, T::Value: Mul<R::Value, Output = TO>, F::Value: Mul<R::Value, Output = FO>,

Source§

type Output = If<C, Mul<T, R, TO>, Mul<F, R, FO>>

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl<C, T, F, R, TO, FO> Rem<R> for If<C, T, F>
where C: Moment<Value = bool>, T: Moment, F: Moment, R: Moment, TO: Moment, FO: Moment, T::Value: Rem<R::Value, Output = TO>, F::Value: Rem<R::Value, Output = FO>,

Source§

type Output = If<C, Rem<T, R, TO>, Rem<F, R, FO>>

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: R) -> Self::Output

Performs the % operation. Read more
Source§

impl<C, T, F, R, TO, FO> Sub<R> for If<C, T, F>
where C: Moment<Value = bool>, T: Moment, F: Moment, R: Moment, TO: Moment, FO: Moment, T::Value: Sub<R::Value, Output = TO>, F::Value: Sub<R::Value, Output = FO>,

Source§

type Output = If<C, Sub<T, R, TO>, Sub<F, R, FO>>

The resulting type after applying the - operator.
Source§

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

Performs the - operation. Read more

Auto Trait Implementations§

§

impl<C, T, F> Freeze for If<C, T, F>
where C: Freeze, T: Freeze, F: Freeze,

§

impl<C, T, F> RefUnwindSafe for If<C, T, F>

§

impl<C, T, F> Send for If<C, T, F>

§

impl<C, T, F> Sync for If<C, T, F>

§

impl<C, T, F> Unpin for If<C, T, F>
where C: Unpin, T: Unpin, F: Unpin,

§

impl<C, T, F> UnwindSafe for If<C, T, F>
where C: UnwindSafe, T: UnwindSafe, F: 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<I, O> AsConvert<O> for I
where I: Moment, O: Moment, <I as Moment>::Value: Into<O>,

Source§

fn to_convert(self) -> Convert<Self, O>

Create a Convert struct from this Moment.
Source§

impl<I, O> AsTryConvert<O> for I
where I: Moment, O: Moment, <I as Moment>::Value: TryInto<O>,

Source§

fn to_try_convert(self) -> TryConvert<Self, O>

Create a TryConvert struct from this Moment.
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, 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.