Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Returning &[u8] support #57

Open
IFcoltransG opened this issue Feb 21, 2024 · 0 comments
Open

Returning &[u8] support #57

IFcoltransG opened this issue Feb 21, 2024 · 0 comments

Comments

@IFcoltransG
Copy link

IFcoltransG commented Feb 21, 2024

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.").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant