pub struct ι<const CHAR: char, Tail>(pub PhantomData<Tail>);Expand description
The Char type, a.k.a. ι, is used to represent type-level list of
chars, which are equivalent to type-level strings.
Char is a specialized version of Cons, with the
Head type being fixed to a const-generic value of type char.
Similar to Cons, Char is also parameterized by a Tail type, which is
expected to be either the next Char, or Nil to
represent the end of the string.
Instead of reusing Cons, we combine the use of Cons within Char so
that its representation is more compact when shown in compiler error messages.
Similar to Cons, Char is also shown as ι to further improve its
readability.
We represent type-level strings as list of Chars, because it is currently
not possible to use types like String or &str as const-generic parameters.
On the other hand, a single char can be used as a const-generic parameter,
and so we can workaround the limitation by combining a type-level list of
chars to represent a type-level string.
Char is most often not used directly, but rather through the symbol! macro,
which accepts a string literal and converts it into a list of Chars.
§Example
Given the following symbol definition:
type Hello = symbol!("hello");The following type would be generated:
type Hello = Char<'h', Char<'e', Char<'l', Char<'l', Char<'o', Nil>>>>>;which would be shown with the shortened representation as:
type Hello = ι<'h', ι<'e', ι<'l', ι<'l', ι<'o', ε>>>>>;Tuple Fields§
§0: PhantomData<Tail>