#[one_hot]
Expand description
The One-hot algorithm.
This procedural macro expects an enum
item where all variants are annotated with either the
matches
attribute, or the wilcard
attribute. It accepts no arguments.
The matches
attribute takes a description of the set of bytes mapped to the corresponding enum
variant. This description takes one of the the following forms:
- A single byte literal, e.g.
#[matches(b'\xA')]
) - A set of byte literals separated by a vartical bat, e.g.
#[matches(b'\xA' | b'\xD')]
- An range of byte literals where the start (inclusive) and the end (exclusive) are join by two
dots, e.g.
#[matches(b'\xA'..b'\xD')]
The wilcard
attribute must be present on exactly one of the enum variants. It signifies the
value to which all non-matched bytes are mapped.
See OneHot
for more information.