Crate alphabet_macro

Source
Expand description

Provides the alphabet!() macro. It can be used to create const alphabets easily.

Usually you would have to write alphabets in a cumbersome way:

const HEX: [char; 16] = ['0', '1', '2', '3',
    '4', '5', '6', '7',
    '8', '9', 'a', 'b',
    'c', 'd', 'e', 'f'];

assert_eq!(HEX.len(), 16);
assert_eq!(HEX[5], '5');
assert_eq!(HEX[10], 'a');

But with the alphabet!() macro this can be done way easier.

use alphabet_macro::alphabet;

alphabet!(HEX = "0123456789abcdef");

assert_eq!(HEX.len(), 16);
assert_eq!(HEX[5], '5');
assert_eq!(HEX[10], 'a');

The alphabet!() macro expands to the snippet above, while being easier to read, write and understand.

Macrosยง

  • Declares a constant alphabet. You can choose any valid identifier as the name for the alphabet.