Trait CoproductMappable
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§
type Output
Required Methods§
fn 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§
§impl<'a, F, R, MapperTail, CH, CTail> CoproductMappable<&'a HCons<F, MapperTail>> for Coproduct<CH, CTail>
Implementation for mapping a Coproduct using a &hlist!
.
impl<'a, F, R, MapperTail, CH, CTail> CoproductMappable<&'a HCons<F, MapperTail>> for Coproduct<CH, CTail>
Implementation for mapping a Coproduct using a &hlist!
.
type Output = Coproduct<R, <CTail as CoproductMappable<&'a MapperTail>>::Output>
§impl<'a, F, R, MapperTail, CH, CTail> CoproductMappable<&'a mut HCons<F, MapperTail>> for Coproduct<CH, CTail>
Implementation for mapping a Coproduct using a &mut hlist!
.
impl<'a, F, R, MapperTail, CH, CTail> CoproductMappable<&'a mut HCons<F, MapperTail>> for Coproduct<CH, CTail>
Implementation for mapping a Coproduct using a &mut hlist!
.
type Output = Coproduct<R, <CTail as CoproductMappable<&'a mut MapperTail>>::Output>
§impl<'a, P, CH, CTail> CoproductMappable<&'a Poly<P>> for Coproduct<CH, CTail>
Implementation for mapping a Coproduct using a &poly_fn!
.
impl<'a, P, CH, CTail> CoproductMappable<&'a Poly<P>> for Coproduct<CH, CTail>
Implementation for mapping a Coproduct using a &poly_fn!
.
§impl<'a, P, CH, CTail> CoproductMappable<&'a mut Poly<P>> for Coproduct<CH, CTail>
Implementation for mapping a Coproduct using a &mut poly_fn!
.
impl<'a, P, CH, CTail> CoproductMappable<&'a mut Poly<P>> for Coproduct<CH, CTail>
Implementation for mapping a Coproduct using a &mut poly_fn!
.
§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.
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>
§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!
.
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>
§impl<P, CH, CTail> CoproductMappable<Poly<P>> for Coproduct<CH, CTail>
Implementation for mapping a Coproduct using a poly_fn!
.
impl<P, CH, CTail> CoproductMappable<Poly<P>> for Coproduct<CH, CTail>
Implementation for mapping a Coproduct using a poly_fn!
.