[−][src]Macro hyperbole::r
Expands to an hlist that may contain named fields.
Named fields are used to disambiguate elements of the same type, as most logic in this crate depends on types being unique within hlists.
Any invocation may contain an arbitrary number of comma separated elements of the form expr
or name = expr
. Optionally, ...expr
may be added to the end in order to append the elements
of another hlist.
The R! macro may be used to name the type of the produced hlist.
Examples
As hlists are effectively singly linked lists at the type level, the simplest way to refer to an individual element is to follow the struct fields directly:
use hyperbole::r; let rec = r![1, 2, 3]; assert_eq!(rec.head, 1); assert_eq!(rec.tail.head, 2); assert_eq!(rec.tail.tail.head, 3);
Alternatively, they can be converted into tuples:
use hyperbole::r; let rec = r![1, "foo", "bar".to_owned()]; let (a, b, c) = rec.into(); assert_eq!(a, 1); assert_eq!(b, "foo"); assert_eq!(c, "bar");
See HCons for more advanced usage.