pub fn map_or<W, G, H, A>(
        self,
        default: A,
        f: impl Fn(V) -> Anim<H>,
    ) -> Anim<impl Fun<T = F::T, V = W>>
    where
        G: Fun<T = F::T, V = W>,
        H: Fun<T = F::T, V = W>,
        A: Into<Anim<G>>,
    {
        let default = default.into();

        //self.bind(move |v| v.map_or(default, f))

        fun(move |t| {
            self.eval(t)
                .map_or_else(|| default.eval(t), |v| f(v).eval(t))
        })
    }
/// Applies a function to the contained value (if any), or returns the
/// provided default (if not).
///
/// Note that the function `f` itself returns an animation.
///
/// # Example
///
/// Animate a player's position offset if it is moving:
/// ```
/// # use assert_approx_eq::assert_approx_eq;
/// fn my_offset_anim(
///     move_dir: Option<f32>,
/// ) -> pareen::Anim<impl pareen::Fun<T = f32, V = f32>> {
///     let move_speed = 2.0f32;
///
///     pareen::constant(move_dir).map_or(
///         0.0,
///         move |move_dir| pareen::prop(move_dir) * move_speed,
///     )
/// }
///
/// let move_anim = my_offset_anim(Some(1.0));
/// let stay_anim = my_offset_anim(None);
///
/// assert_approx_eq!(move_anim.eval(0.5), 1.0);
/// assert_approx_eq!(stay_anim.eval(0.5), 0.0);
/// ```
Applies a function to the contained value (if any), or returns the
provided default (if not).

Note that the function `f` itself returns an animation.
Applies a function to the contained value ( if any ) or returns the provided default ( if not ) . Note that the function ` f ` itself returns an animation .
pub fn map_or<W, G, H, A>(
        self,
        default: A,
        f: impl Fn(V) -> Anim<H>,
    ) -> Anim<impl Fun<T = F::T, V = W>>
    where
        G: Fun<T = F::T, V = W>,
        H: Fun<T = F::T, V = W>,
        A: Into<Anim<G>>,
    {
        let default = default.into();
        //self.bind(move |v| v.map_or(default, f))
        fun(move |t| {
            self.eval(t)
                .map_or_else(|| default.eval(t), |v| f(v).eval(t))
        })
    }
pub fn map_or < W , G , H , A > ( self , default : A , f : impl Fn ( V ) -> Anim < H > , ) -> Anim < impl Fun < T = F :: T , V = W > > where G : Fun < T = F :: T , V = W > , H : Fun < T = F :: T , V = W > , A : Into < Anim < G > > , { let default = default . into ( ) ; //self.bind(move |v| v.map_or(default, f)) fun ( move | t | { self . eval ( t ) . map_or_else ( | | default . eval ( t ) , | v | f ( v ) . eval ( t ) ) } ) }
Applies a function to the contained value (if any), or returns the
provided default (if not).
Applies a function to the contained value ( if any ) or returns the provided default ( if not ) .
self
default
A
f
impl Fn(V) -> Anim<H>
example
Animate a player's position offset if it is moving:
```
Animate a player ' s position offset if it is moving : ` ` `
use assert_approx_eq::assert_approx_eq;
fn my_offset_anim(
move_dir: Option,
) -> pareen::Anim> {
let move_speed = 2.0f32.

:constant(move_dir).map_or(
0.0,
move |move_dir| pareen::prop(move_dir) * move_speed,
)
}

let move_anim = my_offset_anim(Some(1.0));
let stay_anim = my_offset_anim(None).


fn my_offset_anim ( move_dir : Option ) - > pareen :: Anim > { let move_speed = 2 . 0f32 . : constant ( move_dir ) . map_or ( 0 . 0 move |move_dir| pareen :: prop ( move_dir ) * move_speed ) } let move_anim = my_offset_anim ( Some ( 1 . 0 )) ; let stay_anim = my_offset_anim ( None ) .