I am reading a binary file in, and I want to convert the byte I'm reading into a char. I looked at the std::ascii examples I could find, but it seems like it has been depreciated? I want to try and make something like this:
let mut ascii_string: String;
if (! byte_pair[0].is_ascii_printable())
{
ascii_string.push(byte_pair[0].as_char())
}
I have found this:
let c1 = Some(char::from_digit(byte_pair[0].into(), 16));
but it returns an Option, which isn't really what I want. It does contain the correct character, but I have no idea how to convert this into a character which can be pushed into a string. It seems an awfully convoluted method for just pushing an ascii code into a string variable. There must be a better way.