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
type Output
Required Methods
fn foldl(self, folder: Folder, i: Init) -> Self::Output
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
impl<F, Acc> HZipFoldLeftable<F, Acc> for HNil
impl<F, FolderHeadR, FolderTail, H, Tail, Acc> HZipFoldLeftable<HCons<F, FolderTail>, Acc> for HCons<H, Tail> where Tail: HZipFoldLeftable<FolderTail, FolderHeadR>,
F: Fn(Acc, H) -> FolderHeadR