[][src]Macro hyperbole::R

macro_rules! R {
    () => { ... };
    ($name:ident : $type:ty) => { ... };
    ($name:ident : $type:ty , $( $tok:tt )*) => { ... };
    ($type:ty) => { ... };
    ($type:ty , $( $tok:tt )*) => { ... };
    (... $tail:ty) => { ... };
}

Expands to the type of 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 Type or name: Type. Optionally, ...Type may be added to the end in order to append the elements of another hlist.

The r! macro may be used to instantiate an hlist value.

Examples

use frunk_core::hlist::{HCons, HNil};
use hyperbole::{f, R};

type T = R![u16, u32, u64];
type _T = HCons<u16, HCons<u32, HCons<u64, HNil>>>;
assert_type_eq!(T, _T);

type U = R![x: u16, y: u32, z: u64];
type _U = HCons<f![x: u16], HCons<f![y: u32], HCons<f![z: u64], HNil>>>;
assert_type_eq!(U, _U);

type V = R![u16, x: u32, u64];
type _V = HCons<u16, HCons<f![x: u32], HCons<u64, HNil>>>;
assert_type_eq!(V, _V);

type W = R![foo: String, ...T];
type _W = HCons<f![foo: String], HCons<u16, HCons<u32, HCons<u64, HNil>>>>;
assert_type_eq!(W, _W);