[−][src]Trait pareen::Fun
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.