const_format_crates
const_format_crates copied to clipboard
Returning `&[u8]` support
For my use case I need byte slices composed mostly of ASCII with some arbitrary bytes thrown in as escapes. I hoped I could do something like this:
const data: &[u8] = formatcp!(b"Here is a 'string' with invalid UTF8 {INVALID_UNICODE} in it.", INVALID_UNICODE=[0xa0, 0xa1]);
To do this with const_format
, I'd need a version of formatcp!
that returns a byte slice literal, rather than a &str
.
Feel free to close if creating &[u8]
rather than &str
is out of scope for these crates. As a workaround I'll use a slice concatenation crate, more like concat_bytes!(b"Here is a 'string' with invalid UTF8 ", INVALID_UNICODE, " in it.")
.