Crate hexadecimal_digits

Crate hexadecimal_digits 

Source
Expand description

§Hexadecimal Digits

Provides uppercase and lowercase hexadecimal digit character tables


Have you ever needed to build an array of hexadecimal digits, but you’re too lazy to do it yourself? Well you’ve come to the right place! This Rust crate comes with both uppercase and lowercase arrays of all 16 hexadecimal digits!

§Usage

The hexadecimal digits are stored simply as an array of chars. There’s nothing fancy happening here. Just use them the same way you would with other arrays.

§Importing

You can import either the uppercase and/or lowercase modules like:

use hexadecimal_digits::{
    lowercase,
    uppercase,
};

§Invocation

When you need to use one of the arrays, you can invoke them like:

let lowercase_hexadecimal_a: char = lowercase::HEXADECIMAL_DIGITS[10];
let uppercase_hexadecimal_f: char = uppercase::HEXADECIMAL_DIGITS[15];

§Re-Exports

If you don’t like how long the array names are, re-exports of both arrays with shorter names are available for you to use instead like:

let lowercase_hexadecimal_a: char = lowercase::HEX_DIGITS[10];
let uppercase_hexadecimal_f: char = uppercase::HEX_DIGITS[15];

§Custom Imports

Of course, you can always import them however you want and assign custom names for your own projects, like:

use hexadecimal_digits::lowercase::HEXADECIMAL_DIGITS as HEX_LOWER;
use hexadecimal_digits::uppercase::HEXADECIMAL_DIGITS as HEX_UPPER;

§Example

Here’s an example of you can do with this crate:

§Hexadecimal Permutations

This example generates all possible 8-bit hexadecimal numbers.

for digit_1 in lowercase::HEXADECIMAL_DIGITS {
    for digit_2 in lowercase::HEXADECIMAL_DIGITS {
        println!("{digit_1}{digit_2}");
    }
}

Modules§

lowercase
Provides an array of lowercase hexadecimal digits
uppercase
Provides an array of uppercase hexadecimal digits