Trait fmap::Functor

source ·
pub trait Functor<'a, B>where
    Self: Identity<Self::Map<'a, Self::Inner>>,
    B: 'a,{
    type Inner: 'a;
    type Mapped<'b>: Functor<'b, B> + Identity<Self::Map<'b, B>>
       where B: 'b,
             'a: 'b;
    type Map<'b, C>
       where C: 'a,
             'a: 'b;

    // Required method
    fn fmap<'b, F>(self, f: F) -> Self::Mapped<'b>
       where F: Fn(Self::Inner) -> B + 'b,
             'a: 'b;
}
Expand description

A type constructed by a functor (e.g. Option<T> or Vec<T>)

Required Associated Types§

source

type Inner: 'a

Inner type

source

type Mapped<'b>: Functor<'b, B> + Identity<Self::Map<'b, B>> where B: 'b, 'a: 'b

Self with inner type mapped to B (where B is a type parameter of this trait)

source

type Map<'b, C> where C: 'a, 'a: 'b

Self with inner type mapped to C (where C is a type parameter of this GAT)

Required Methods§

source

fn fmap<'b, F>(self, f: F) -> Self::Mapped<'b>where F: Fn(Self::Inner) -> B + 'b, 'a: 'b,

Replaces inner type and value by applying a mapping function

Implementations on Foreign Types§

source§

impl<'a, A, B> Functor<'a, B> for Option<A>where A: 'a, B: 'a,

§

type Inner = A

§

type Mapped<'b> where B: 'b, 'a: 'b = Option<B>

§

type Map<'b, C> where C: 'a, 'a: 'b = Option<C>

source§

fn fmap<'b, F>(self, f: F) -> Option<B>where F: Fn(A) -> B + 'b, 'a: 'b,

source§

impl<'a, A, B> Functor<'a, B> for LinkedList<A>where A: 'a, B: 'a,

§

type Inner = A

§

type Mapped<'b> where B: 'b, 'a: 'b = LinkedList<B, Global>

§

type Map<'b, C> where C: 'a, 'a: 'b = LinkedList<C, Global>

source§

fn fmap<'b, F>(self, f: F) -> LinkedList<B>where F: Fn(A) -> B + 'b, 'a: 'b,

source§

impl<'a, A, B> Functor<'a, B> for BinaryHeap<A>where A: 'a + Ord, B: 'a + Ord,

§

type Inner = A

§

type Mapped<'b> where B: 'b, 'a: 'b = BinaryHeap<B>

§

type Map<'b, C> where C: 'a, 'a: 'b = BinaryHeap<C>

source§

fn fmap<'b, F>(self, f: F) -> BinaryHeap<B>where F: Fn(A) -> B + 'b, 'a: 'b,

source§

impl<'a, A, B, E> Functor<'a, B> for Result<A, E>where A: 'a, B: 'a,

§

type Inner = A

§

type Mapped<'b> where B: 'b, 'a: 'b = Result<B, E>

§

type Map<'b, C> where C: 'a, 'a: 'b = Result<C, E>

source§

fn fmap<'b, F>(self, f: F) -> Result<B, E>where F: Fn(A) -> B + 'b, 'a: 'b,

source§

impl<'a, K, A, B> Functor<'a, B> for BTreeMap<K, A>where K: Ord, A: 'a, B: 'a,

§

type Inner = A

§

type Mapped<'b> where B: 'b, 'a: 'b = BTreeMap<K, B, Global>

§

type Map<'b, C> where C: 'a, 'a: 'b = BTreeMap<K, C, Global>

source§

fn fmap<'b, F>(self, f: F) -> BTreeMap<K, B>where F: Fn(A) -> B + 'b, 'a: 'b,

source§

impl<'a, A, B> Functor<'a, B> for HashSet<A>where A: 'a + Eq + Hash, B: 'a + Eq + Hash,

§

type Inner = A

§

type Mapped<'b> where B: 'b, 'a: 'b = HashSet<B, RandomState>

§

type Map<'b, C> where C: 'a, 'a: 'b = HashSet<C, RandomState>

source§

fn fmap<'b, F>(self, f: F) -> HashSet<B>where F: Fn(A) -> B + 'b, 'a: 'b,

source§

impl<'a, A, B> Functor<'a, B> for BTreeSet<A>where A: 'a + Ord, B: 'a + Ord,

§

type Inner = A

§

type Mapped<'b> where B: 'b, 'a: 'b = BTreeSet<B, Global>

§

type Map<'b, C> where C: 'a, 'a: 'b = BTreeSet<C, Global>

source§

fn fmap<'b, F>(self, f: F) -> BTreeSet<B>where F: Fn(A) -> B + 'b, 'a: 'b,

source§

impl<'a, K, A, B> Functor<'a, B> for HashMap<K, A>where K: Eq + Hash, A: 'a, B: 'a,

§

type Inner = A

§

type Mapped<'b> where B: 'b, 'a: 'b = HashMap<K, B, RandomState>

§

type Map<'b, C> where C: 'a, 'a: 'b = HashMap<K, C, RandomState>

source§

fn fmap<'b, F>(self, f: F) -> HashMap<K, B>where F: Fn(A) -> B + 'b, 'a: 'b,

source§

impl<'a, A, B> Functor<'a, B> for Box<dyn Iterator<Item = A> + 'a>where A: 'a, B: 'a,

§

type Inner = A

§

type Mapped<'b> where B: 'b, 'a: 'b = Box<dyn Iterator<Item = B> + 'b, Global>

§

type Map<'b, C> where C: 'a, 'a: 'b = Box<dyn Iterator<Item = C> + 'b, Global>

source§

fn fmap<'b, F>(self, f: F) -> Self::Mapped<'b>where F: 'b + Fn(A) -> B, 'a: 'b,

source§

impl<'a, A, B> Functor<'a, B> for VecDeque<A>where A: 'a, B: 'a,

§

type Inner = A

§

type Mapped<'b> where B: 'b, 'a: 'b = VecDeque<B, Global>

§

type Map<'b, C> where C: 'a, 'a: 'b = VecDeque<C, Global>

source§

fn fmap<'b, F>(self, f: F) -> VecDeque<B>where F: Fn(A) -> B + 'b, 'a: 'b,

source§

impl<'a, A, B> Functor<'a, B> for Vec<A>where A: 'a, B: 'a,

§

type Inner = A

§

type Mapped<'b> where B: 'b, 'a: 'b = Vec<B, Global>

§

type Map<'b, C> where C: 'a, 'a: 'b = Vec<C, Global>

source§

fn fmap<'b, F>(self, f: F) -> Vec<B>where F: Fn(A) -> B + 'b, 'a: 'b,

Implementors§