Trait frunk_core::hlist::HFoldRightable [] [src]

pub trait HFoldRightable<Folder, Init, Index> {
    type Output;
    fn foldr(self, folder: Folder, i: Init) -> Self::Output;
}

Foldr for HLists

Associated Types

Required Methods

foldr over a data structure

Sadly, due to a compiler quirk, only the value-consuming (the original hlist) variant exists for foldr.

Examples

let nil = HNil;

assert_eq!(nil.foldr(HNil, 0), 0);

let h = hlist![1, false, 42f32];

let folded = h.foldr(
    hlist![
        |i, acc| i + acc,
        |b: bool, acc| if !b && acc > 42f32 { 9000 } else { 0 },
        |f, acc| f + acc
    ],
    1f32
);

assert_eq!(9001, folded)
Run

Implementors