Trait frunk_core::hlist::HMappable [] [src]

pub trait HMappable<Mapper> {
    type Output;
    fn map(self, folder: Mapper) -> Self::Output;
}

Trail that allow for mapping over a data structure using mapping functions stored in another data structure

It might be a good idea to try to re-write these using the foldr variants, but it's a wee-bit more complicated.

Associated Types

Required Methods

Maps over the current data structure using functions stored in another data structure.


let nil = HNil;

assert_eq!(nil.map(HNil), HNil);

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

// Sadly we need to help the compiler understand the bool type in our mapper

let mapped = h.map(hlist![
    |n| n + 1,
    |b: bool| !b,
    |f| f + 1f32]);
assert_eq!(mapped, hlist![2, true, 43f32]);Run

Implementors