hlist

Macro hlist 

Source
macro_rules! hlist {
    () => { ... };
    ($head:ident $(,)?) => { ... };
    ($head:ident, $($tail:ident),* $(,)?) => { ... };
    ($head:expr $(,)?) => { ... };
    ($head:expr, $($tail:expr),* $(,)?) => { ... };
}
Expand description

Macro creating heterogenous list values from list of expressions.

This macro supports trailing comma at the end of list of expressions.

ยงExamples

This macro can be used to create heterogenous list as easily as tuple without cons-nil boilerplate:

use hlist2::{hlist, Cons, Nil};

let list = hlist![1, 2.0, true];
assert_eq!(list, Cons(1, Cons(2.0, Cons(true, Nil))));

Also it can be used in pattern matching. For example, we can destruct heterogenous list to its values:

use hlist2::hlist;

let hlist![a, b, c, d] = hlist![10, -15.0, "hello world", false];
assert_eq!((a, b, c, d), (10, -15.0, "hello world", false));