The documentation for hir::literal says:
Creates a literal HIR expression.
This accepts anything that can be converted into a Box<[u8]>.
I'm trying to create an hir::Literal from a char, which, as far as I know, doesn't provide a conversion to a Box<[u8]>. In the end, I did this:
// "A buffer of length four is large enough to encode any
// char."
//
// https://doc.rust-lang.org/std/primitive.char.html#method.encode_utf8
let mut buffer = [0; 4];
// Convert the Unicode character t to a string.
let s = t.to_char().encode_utf8(&mut buffer);
hir::Hir::literal(s.as_bytes())
It would be nice if the documentation for literal included this (or something better?) as an example, or Hir had a convenience function, perhaps literal_char, that does this.