pub trait CoproductFoldable<Folder, Output> {
    // Required method
    fn fold(self, f: Folder) -> Output;
Expand description

Trait for folding a coproduct into a single value.

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

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

Required Methods§


fn fold(self, f: Folder) -> Output

Use functions to fold a coproduct into a single value.

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)



impl<F, R> CoproductFoldable<F, R> for CNil

This is literally impossible; CNil is not instantiable


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


impl<P, R, CH, CTail> CoproductFoldable<Poly<P>, R> for Coproduct<CH, CTail>
where P: Func<CH, Output = R>, CTail: CoproductFoldable<Poly<P>, R>,