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>
impl<C: Moment<Value = bool>, T: Moment, F: Moment> If<C, T, F>
Sourcepub fn new(condition: C, then: T, otherwise: F) -> Self
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.
Sourcepub async fn to_otherwise(self) -> Option<F>
pub async fn to_otherwise(self) -> Option<F>
Tries to get the otherwise calculation.
Trait Implementations§
Source§impl<C: Clone + Moment<Value = bool>, T: Clone + Moment, F: Clone + Moment> Clone for If<C, T, F>
impl<C: Clone + Moment<Value = bool>, T: Clone + Moment, F: Clone + Moment> Clone for If<C, T, F>
Source§impl<C, T, F> Moment for If<C, T, F>
impl<C, T, F> Moment for If<C, T, F>
Auto Trait Implementations§
impl<C, T, F> Freeze for If<C, T, F>
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>
impl<C, T, F> UnwindSafe for If<C, T, F>
Blanket Implementations§
Source§impl<I, O> AsTryConvert<O> for I
impl<I, O> AsTryConvert<O> for I
Source§fn to_try_convert(self) -> TryConvert<Self, O>
fn to_try_convert(self) -> TryConvert<Self, O>
Create a
TryConvert struct from this Moment.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