Trait frunk_core::hlist::HFoldLeftable [−][src]
Trait for performing a left fold over an HList
This trait is part of the implementation of the inherent method
HCons::foldl
. Please see that method for more information.
You only need to import this trait when working with generic
HLists or Mappers of unknown type. If the type of everything is known,
then list.foldl(f, acc)
should “just work” even without the trait.
Associated Types
Loading content...Required methods
fn foldl(self, folder: Folder, acc: Acc) -> Self::Output
[src]
Perform a left fold over an HList.
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)
Implementors
impl<F, Acc> HFoldLeftable<F, Acc> for HNil
[src]
impl<F, H, Tail, Acc> HFoldLeftable<F, Acc> for HCons<H, Tail> where
Tail: HFoldLeftable<F, Acc>,
F: Fn(Acc, H) -> Acc,
[src]
Tail: HFoldLeftable<F, Acc>,
F: Fn(Acc, H) -> Acc,
Implementation for folding over an HList using a single function that can handle all cases
let h = hlist![1, 2, 3, 4, 5]; let r: isize = h.foldl(|acc, next| acc + next, 0); assert_eq!(r, 15);Run
type Output = <Tail as HFoldLeftable<F, Acc>>::Output
fn foldl(self, f: F, acc: Acc) -> Self::Output
[src]
impl<F, R, FTail, H, Tail, Acc> HFoldLeftable<HCons<F, FTail>, Acc> for HCons<H, Tail> where
Tail: HFoldLeftable<FTail, R>,
F: FnOnce(Acc, H) -> R,
[src]
Tail: HFoldLeftable<FTail, R>,
F: FnOnce(Acc, H) -> R,
type Output = <Tail as HFoldLeftable<FTail, R>>::Output
fn foldl(self, folder: HCons<F, FTail>, acc: Acc) -> Self::Output
[src]
impl<P, R, H, Tail, Acc> HFoldLeftable<Poly<P>, Acc> for HCons<H, Tail> where
Tail: HFoldLeftable<Poly<P>, R>,
P: Func<(Acc, H), Output = R>,
[src]
Tail: HFoldLeftable<Poly<P>, R>,
P: Func<(Acc, H), Output = R>,