pub trait Functor<'a, A> {
type Target<T>;
// Required method
fn fmap<B, F>(self, f: F) -> Self::Target<B>
where F: Fn(A) -> B + 'a;
}
Expand description
A Functor
lets you change the type parameter of a generic type.
A Functor
defines a method fmap
on a type F<_>: Functor
which converts
an F<A>
to F<B>
using a function Fn(A) -> B
applied to the A
s inside
it.
You can also use this just to modify the values inside your container value without changing their type, if the mapping function returns a value of the same type. This is called an “endofunctor.”
Required Associated Types§
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.