If you want to get a literal (as in &'static str
), you could do this:
fn to_byte_string_literal(a: &'static impl AsRef<[u8]>) -> &'static str {
std::str::from_utf8(a.as_ref()).unwrap()
}
fn main() {
assert_eq!(to_byte_string_literal(&[30, 31, 30, 30, 43]), "\x1E\x1F\x1E\x1E+");
}
But I'm not sure if I understand your question correctly.