Trait frunk::hlist::foldr_owned::HFoldRightableOwned
source · pub trait HFoldRightableOwned<Folder, Init>: HFoldRightable<Folder, Init> {
// Required method
fn real_foldr(self, folder: Folder, init: Init) -> (Self::Output, Folder);
}
Expand description
A real foldr
for the folder that must be owned to fold.
Due to HList
being a recursive struct and not linear array,
the only way to fold it is recursive.
However, there are differences in the foldl
and foldr
traversing
the HList
:
foldl
callsfolder(head)
and then passes the ownership of the folder to the next recursive call.foldr
passes the ownership of the folder to the next recursive call, and then tries to callfolder(head)
; but the ownership is already gone!