Trait frunk_core::hlist::LiftInto

source ·
pub trait LiftInto<T, I> {
    // Required method
    fn lift_into(self) -> T;
}
Expand description

An indexed conversion that consumes self, and produces a T. To produce T, the index I may be used to for example “fill in the blanks”. LiftInto is the reciprocal of LiftFrom.

use frunk::prelude::*;
use frunk_core::{HList, hlist};

type H = HList![(), usize, f64, (), bool];

// Type inference works as expected:
let x: H = 1337.lift_into();
assert_eq!(x, hlist![(), 1337, 0.0, (), false]);

// Sublists:
let x: H = hlist![(), true].lift_into();
assert_eq!(x, hlist![(), 0, 0.0, (), true]);

let x: H = hlist![3.0, ()].lift_into();
assert_eq!(x, hlist![(), 0, 3.0, (), false]);

let x: H = hlist![(), 1337].lift_into();
assert_eq!(x, hlist![(), 1337, 0.0, (), false]);

let x: H = hlist![(), 1337, 42.0, (), true].lift_into();
assert_eq!(x, hlist![(), 1337, 42.0, (), true]);

Required Methods§

source

fn lift_into(self) -> T

Performs the indexed conversion.

Implementors§

source§

impl<T, U, I> LiftInto<U, I> for T
where U: LiftFrom<T, I>,