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1, -1,
0, 1, 2, 3, 4, 5, 6,
7, 8, 9, -1, -1, -1, -1,
-1, -1, -1, 10, 11, 12, 13,
14, 15, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1,
10, 11, 12, 13, 14, 15, -1,
-1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1 ];
#[allow(dead_code)]
pub fn from_hex_bytes_to_value_bytes() -> [i16; 256] {
let mut array = [-1; 256];
for index in 0..256usize {
match index as u8{
b'0'..=b'9' => array[index] = (index as u8 - b'0') as i16,
b'A'..=b'F' => array[index] = (index as u8 - b'A' + 10) as i16,
b'a'..=b'f' => array[index] = (index as u8 - b'a' + 10) as i16,
_ => continue ,
}
}
array
}
#[allow(dead_code)]
pub fn printable_array<T>(array: Vec<T>, number_before_linebreak: u8)
where T: Display{
let mut current_number: u8 = 0;
print!("[");
for (index, current) in array.iter().enumerate() {
if current_number >= number_before_linebreak {
current_number = 0;
println!();
} else {
current_number += 1;
}
print!(
"{}{} ",
current,
if index == array.len() - 1 { "" } else { "," }
);
}
print!("]");
}
#[allow(dead_code)]
pub fn preprocess_ascii_convertable() -> [u8; 256] {
let mut array = [0_u8; 256];
for index in 0..=255u8 {
match index as char {
'a'..='z' | 'A'..='Z' | '0'..='9' | '-' | '_' | '.' | '~' => {
array[index as usize] = 1u8
}
_ => array[index as usize] = 0u8,
}
}
array
}