1 unstable release
0.4.0 | Jan 29, 2025 |
---|
#737 in Development tools
141 downloads per month
20KB
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
Adding to your project
You can use cargo add hexadecimal-digits
to add the crate to your project!
Using it in your project
After adding the crate to your project, you can import either the uppercase and/or lowercase modules:
use hexadecimal_digits::{
lowercase,
uppercase,
};
When you need to use one of the arrays, you can invoke them like this:
let hexadecimal_a: char = lowercase::HEXADECIMAL_DIGITS[10];
Licensing
This project is licensed under the terms of the MIT license.
lib.rs
:
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
char
s.
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}");
}
}