[][src]Trait pareen::Fun

pub trait Fun {
    type T;
    type V;
    fn eval(&self, t: Self::T) -> Self::V;
}

A Fun represents anything that maps from some type T to another type V.

T usually stands for time and V for some value that is parameterized by time.

Implementation details

The only reason that we define this trait instead of just using Fn(T) -> V is so that the library works in stable rust. Having this type allows us to implement e.g. std::ops::Add for Anim<F> where F: Fun. Without this trait, it becomes difficult (impossible?) to provide a name for Add::Output, unless you have the unstable feature type_alias_impl_trait or fn_traits.

In contrast to std::ops::FnOnce, both input and output are associated types of Fun. The main reason is that this makes types smaller for the user of the library. I have not observed any downsides to this yet.

Associated Types

type T

The function's input type. Usually time.

type V

The function's output type.

Loading content...

Required methods

fn eval(&self, t: Self::T) -> Self::V

Evaluate the function at time t.

Loading content...

Implementors

Loading content...