pl-hlist
This Rust library provides support for heterogeneous lists (known as HLists). An HList is a functional,
tuple-like, strongly-typed data structure that can contain elements of differing types.
There are three layers in this library:
- A basic
HListdata structure consisting ofHConsandHNiltypes. - An
hlist!macro for constructing anHListfrom a series of elements. - An
HListSupportplugin/attribute that, when declared for a struct, allows for easy conversion of struct instances to/from anHListrepresentation.
See the next section for more details on usage of these layers.
Usage
Add a dependency to your Cargo.toml:
[]
= "1.0"
Then, in your crate:
use *;
An HList can be constructed manually as follows:
let x: = HCons;
The hlist! macro provides a convenient shorthand for constructing an HList:
let x: = hlist!;
The custom HListSupport derive attribute can be applied to a struct declaration to automatically implement support for converting that struct to/from an HList representation:
let hlist0 = hlist!;
let s = from_hlist;
assert_eq!;
assert_eq!;
let hlist1 = s.into_hlist;
assert_eq!;
License
pl-hlist is distributed under an MIT license. See LICENSE for more details.