Trait frunk_core::coproduct::CoproductMappable
source · 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§
sourcefn map(self, f: Mapper) -> Self::Output
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>,
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!
.
type Output = Coproduct<R, <CTail as CoproductMappable<&'a MapperTail>>::Output>
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>,
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!
.
type Output = Coproduct<R, <CTail as CoproductMappable<&'a mut MapperTail>>::Output>
source§impl<'a, P, CH, CTail> CoproductMappable<&'a Poly<P>> for Coproduct<CH, CTail>where
P: Func<CH>,
CTail: CoproductMappable<&'a Poly<P>>,
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!
.
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>>,
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!
.
source§impl<F, R, CH, CTail> CoproductMappable<F> for Coproduct<CH, CTail>where
F: FnMut(CH) -> R,
CTail: CoproductMappable<F>,
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>,
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!
.