pub trait CoproductMappable<Mapper> {
    type Output;

    // Required method
    fn map(self, f: Mapper) -> Self::Output;
}
Expand description

Trait for mapping over a coproduct’s variants.

This trait is part of the implementation of the inherent method Coproduct::map. Please see that method for more information.

You only need to import this trait when working with generic Coproducts or mappers of unknown type. If the type of everything is known, then co.map(mapper) should “just work” even without the trait.

Required Associated Types§

Required Methods§

source

fn map(self, f: Mapper) -> Self::Output

Use functions to map each variant of a coproduct.

Please see the inherent method for more information.

The only difference between that inherent method and this trait method is the location of the type parameters. (here, they are on the trait rather than the method)

Implementors§

source§

impl<'a, F, R, MapperTail, CH, CTail> CoproductMappable<&'a HCons<F, MapperTail>> for Coproduct<CH, CTail>
where F: Fn(CH) -> R, CTail: CoproductMappable<&'a MapperTail>,

Implementation for mapping a Coproduct using a &hlist!.

source§

impl<'a, F, R, MapperTail, CH, CTail> CoproductMappable<&'a mut HCons<F, MapperTail>> for Coproduct<CH, CTail>
where F: FnMut(CH) -> R, CTail: CoproductMappable<&'a mut MapperTail>,

Implementation for mapping a Coproduct using a &mut hlist!.

source§

impl<'a, P, CH, CTail> CoproductMappable<&'a Poly<P>> for Coproduct<CH, CTail>
where P: Func<CH>, CTail: CoproductMappable<&'a Poly<P>>,

Implementation for mapping a Coproduct using a &poly_fn!.

§

type Output = Coproduct<<P as Func<CH>>::Output, <CTail as CoproductMappable<&'a Poly<P>>>::Output>

source§

impl<'a, P, CH, CTail> CoproductMappable<&'a mut Poly<P>> for Coproduct<CH, CTail>
where P: Func<CH>, CTail: CoproductMappable<&'a mut Poly<P>>,

Implementation for mapping a Coproduct using a &mut poly_fn!.

§

type Output = Coproduct<<P as Func<CH>>::Output, <CTail as CoproductMappable<&'a mut Poly<P>>>::Output>

source§

impl<F> CoproductMappable<F> for CNil

Base case map impl.

§

type Output = CNil

source§

impl<F, R, CH, CTail> CoproductMappable<F> for Coproduct<CH, CTail>
where F: FnMut(CH) -> R, CTail: CoproductMappable<F>,

Implementation for mapping a Coproduct using a single function that can handle all variants.

§

type Output = Coproduct<R, <CTail as CoproductMappable<F>>::Output>

source§

impl<F, R, MapperTail, CH, CTail> CoproductMappable<HCons<F, MapperTail>> for Coproduct<CH, CTail>
where F: FnOnce(CH) -> R, CTail: CoproductMappable<MapperTail>,

Implementation for mapping a Coproduct using an hlist!.

§

type Output = Coproduct<R, <CTail as CoproductMappable<MapperTail>>::Output>

source§

impl<P, CH, CTail> CoproductMappable<Poly<P>> for Coproduct<CH, CTail>
where P: Func<CH>, CTail: CoproductMappable<Poly<P>>,

Implementation for mapping a Coproduct using a poly_fn!.

§

type Output = Coproduct<<P as Func<CH>>::Output, <CTail as CoproductMappable<Poly<P>>>::Output>