Trait Functor

Source
pub trait Functor: SelfConstraint {
    type Inner;
    type Structure<A>: Functor<Inner = A>;

    // Required method
    fn fmap<A, B, F>(a: Self::Structure<A>, f: F) -> Self::Structure<B>
       where F: Fn(A) -> B;
}

Required Associated Types§

Source

type Inner

Source

type Structure<A>: Functor<Inner = A>

Required Methods§

Source

fn fmap<A, B, F>(a: Self::Structure<A>, f: F) -> Self::Structure<B>
where F: Fn(A) -> B,

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<T> Functor for Option<T>

Source§

type Inner = T

Source§

type Structure<A> = Option<A>

Source§

fn fmap<A, B, F>(a: Self::Structure<A>, f: F) -> Self::Structure<B>
where F: Fn(A) -> B,

Source§

impl<T> Functor for Vec<T>

Source§

type Inner = T

Source§

type Structure<U> = Vec<U>

Source§

fn fmap<A, B, F>(a: Self::Structure<A>, f: F) -> Self::Structure<B>
where F: Fn(A) -> B,

Source§

impl<T, const M: usize> Functor for [T; M]

Source§

type Inner = T

Source§

type Structure<U> = [U; M]

Source§

fn fmap<A, B, F>(a: Self::Structure<A>, f: F) -> Self::Structure<B>
where F: Fn(A) -> B,

Implementors§

Source§

impl<T> Functor for ExactlyOne<T>

Source§

impl<T, U> Functor for Tuple<T, U>

Source§

type Inner = U

Source§

type Structure<A> = Tuple<T, A>