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
type Output
Required Methods
fn foldr(self, folder: Folder, i: Init) -> Self::Output
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
impl<F, Init> HFoldRightable<F, Init, Here> for HNil type Output = Init;
impl<F, FolderHeadR, FolderTail, H, Tail, Init, Index> HFoldRightable<HCons<F, FolderTail>, Init, There<Index>> for HCons<H, Tail> where
Tail: HFoldRightable<FolderTail, Init, Index>,
F: FnOnce(H, <Tail as HFoldRightable<FolderTail, Init, Index>>::Output) -> FolderHeadR, type Output = FolderHeadR;