Concatenating byte string literals?


In definition of a macro, I need a way to append a b"\0" to the end of the (byte)string literal parameter, to get a static byte slice as the result.

bytes! looks on paper like it could do the job, but: 1) it’s deprecated; 2) it does not even accept bytestring literals as parameters. concat! deals with UTF-8 strings. What else is there to do?

1 Like


Filed a proposal to resurrect bytes! as an RFC draft.



Is there some specific reason Rust doesn’t automatically coalesce adjacent string literals like C does (and also Python)?


closed #4

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.