Trait frunk_core::hlist::HZipFoldLeftable [] [src]

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

Left fold for a given data structure

Associated Types

Required Methods

foldl over a data structure


let nil = HNil;

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

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

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

assert_eq!(42f32, folded)

Implementors