Functor

Trait Functor 

Source
pub trait Functor<F, T>
where F: FnOnce(Self::Elem) -> T,
{ type Cont<U>: ?Sized; type Elem; // Required method fn apply(self, f: F) -> Self::Cont<T>; }
๐Ÿ‘ŽDeprecated since 0.0.7: The Functor trait has been renamed to MapTo and MapInto for better clarity.
Expand description

The Functor trait describes an interface for a higher-kinded type that can be mapped over. The trait is parameterized over a function F and a target type T, allowing for granular control over the mapping process itself, relying on associated types like Cont<U> to define the resulting container type after the mapping operation and the Elem type to specify the type of elements contained within the functor before the mapping operation is applied. Moreover, the apply method takes ownership of the functor allowing for distinct implementations for referenced, mutabled, and owned instances.

Required Associated Typesยง

Source

type Cont<U>: ?Sized

๐Ÿ‘ŽDeprecated since 0.0.7: The Functor trait has been renamed to MapTo and MapInto for better clarity.
Source

type Elem

๐Ÿ‘ŽDeprecated since 0.0.7: The Functor trait has been renamed to MapTo and MapInto for better clarity.

Required Methodsยง

Source

fn apply(self, f: F) -> Self::Cont<T>

๐Ÿ‘ŽDeprecated since 0.0.7: The Functor trait has been renamed to MapTo and MapInto for better clarity.

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.

Implementations on Foreign Typesยง

Sourceยง

impl<'a, U, V, F> Functor<F, V> for &'a Option<U>
where F: FnOnce(&U) -> V,

Sourceยง

type Cont<T> = Option<T>

๐Ÿ‘ŽDeprecated since 0.0.7: The Functor trait has been renamed to MapTo and MapInto for better clarity.
Sourceยง

type Elem = &'a U

๐Ÿ‘ŽDeprecated since 0.0.7: The Functor trait has been renamed to MapTo and MapInto for better clarity.
Sourceยง

fn apply(self, f: F) -> <&'a Option<U> as Functor<F, V>>::Cont<V>

๐Ÿ‘ŽDeprecated since 0.0.7: The Functor trait has been renamed to MapTo and MapInto for better clarity.
Sourceยง

impl<U, V, F> Functor<F, V> for Option<U>
where F: FnOnce(U) -> V,

Sourceยง

type Cont<T> = Option<T>

๐Ÿ‘ŽDeprecated since 0.0.7: The Functor trait has been renamed to MapTo and MapInto for better clarity.
Sourceยง

type Elem = U

๐Ÿ‘ŽDeprecated since 0.0.7: The Functor trait has been renamed to MapTo and MapInto for better clarity.
Sourceยง

fn apply(self, f: F) -> <Option<U> as Functor<F, V>>::Cont<V>

๐Ÿ‘ŽDeprecated since 0.0.7: The Functor trait has been renamed to MapTo and MapInto for better clarity.

Implementorsยง