pub fn cond<T, V, F, G, H, Cond, A, B>(cond: Cond, a: A, b: B) -> Anim<impl Fun<T = T, V = V>>
where
    T: Copy,
    F: Fun<T = T, V = bool>,
    G: Fun<T = T, V = V>,
    H: Fun<T = T, V = V>,
    Cond: Into<Anim<F>>,
    A: Into<Anim<G>>,
    B: Into<Anim<H>>,
{
    let cond = cond.into();
    let a = a.into();
    let b = b.into();

    fun(move |t| if cond.eval(t) { a.eval(t) } else { b.eval(t) })
}
/// Return the value of one of two animations depending on a condition.
///
/// This allows returning animations of different types conditionally.
///
/// Note that the condition `cond` may either be a value `true` and `false`, or
/// it may itself be a dynamic animation of type `bool`.
///
/// For dynamic conditions, in many cases it suffices to use either
/// [`Anim::switch`](struct.Anim.html#method.switch) or
/// [`Anim::seq`](struct.Anim.html#method.seq) instead of this function.
///
/// # Examples
/// ## Constant conditions
///
/// The following example does _not_ compile, because the branches have
/// different types:
/// ```compile_fail
/// let cond = true;
/// let anim = if cond { pareen::constant(1) } else { pareen::id() };
/// ```
///
/// However, this does compile:
/// ```
/// let cond = true;
/// let anim = pareen::cond(cond, 1, pareen::id());
///
/// assert_eq!(anim.eval(2), 1);
/// ```
///
/// ## Dynamic conditions
///
/// ```
/// let cond = pareen::fun(|t| t * t <= 4);
/// let anim_1 = 1;
/// let anim_2 = pareen::id();
/// let anim = pareen::cond(cond, anim_1, anim_2);
///
/// assert_eq!(anim.eval(1), 1); // 1 * 1 <= 4
/// assert_eq!(anim.eval(2), 1); // 2 * 2 <= 4
/// assert_eq!(anim.eval(3), 3); // 3 * 3 > 4
/// ```
Return the value of one of two animations depending on a condition.
This allows returning animations of different types conditionally.




Return the value of one of two animations depending on a condition . This allows returning animations of different types conditionally .
pub fn cond<T, V, F, G, H, Cond, A, B>(cond: Cond, a: A, b: B) -> Anim<impl Fun<T = T, V = V>>
where
    T: Copy,
    F: Fun<T = T, V = bool>,
    G: Fun<T = T, V = V>,
    H: Fun<T = T, V = V>,
    Cond: Into<Anim<F>>,
    A: Into<Anim<G>>,
    B: Into<Anim<H>>,
{
    let cond = cond.into();
    let a = a.into();
    let b = b.into();
    fun(move |t| if cond.eval(t) { a.eval(t) } else { b.eval(t) })
}
pub fn cond < T , V , F , G , H , Cond , A , B > ( cond : Cond , a : A , b : B ) -> Anim < impl Fun < T = T , V = V > > where T : Copy , F : Fun < T = T , V = bool > , G : Fun < T = T , V = V > , H : Fun < T = T , V = V > , Cond : Into < Anim < F > > , A : Into < Anim < G > > , B : Into < Anim < H > > , { let cond = cond . into ( ) ; let a = a . into ( ) ; let b = b . into ( ) ; fun ( move | t | if cond . eval ( t ) { a . eval ( t ) } else { b . eval ( t ) } ) }
Return the value of one of two animations depending on a condition.
Return the value of one of two animations depending on a condition .
cond
Cond
a
A
b
B
examples
None
constant conditions
The following example does _not_ compile, because the branches have
different types:
```compile_fail
let cond = true;
let anim = if cond { pareen::constant(1) } else { pareen::id() };
```

However, this does compile:
```
let cond = true;
let anim = pareen::cond(cond, 1, pareen::id()).


The following example does _not_ compile because the branches have different types : ` ` ` compile_fail let cond = true ; let anim = if cond { pareen :: constant ( 1 ) } else { pareen :: id () } ; ` ` ` However this does compile : ` ` ` let cond = true ; let anim = pareen :: cond ( cond 1 pareen :: id () ) .
dynamic conditions
None