Macro frunk_core::hlist

source ·
macro_rules! hlist {
    () => { ... };
    (...$rest:expr) => { ... };
    ($a:expr) => { ... };
    ($a:expr, $($tok:tt)*) => { ... };
}
Expand description

Returns an HList based on the values passed in.

Helps to avoid having to write nested HCons.

§Examples

let h = hlist![13.5f32, "hello", Some(41)];
let (h1, (h2, h3)) = h.into_tuple2();
assert_eq!(h1, 13.5f32);
assert_eq!(h2, "hello");
assert_eq!(h3, Some(41));

// Also works when you have trailing commas
let h4 = hlist!["yo",];
let h5 = hlist![13.5f32, "hello", Some(41),];
assert_eq!(h4, hlist!["yo"]);
assert_eq!(h5, hlist![13.5f32, "hello", Some(41)]);

// Use "...tail" to append an existing list at the end
let h6 = hlist![12, ...h5];
assert_eq!(h6, hlist![12, 13.5f32, "hello", Some(41)]);