[−][src]Macro byte_strings::concat_bytes
Concatenates byte string literals into a single byte string literal
This macro takes any number of comma-separated byte string literals, and evaluates to (a static reference to) a byte array made of all the bytes of the given byte string literals concatenated left-to-right.
Hence the macro evaluates to the type &'static [u8; N]
(where N is the total number of bytes), which can also "be seen as"
(coerce to) a static byte slice (i.e., &'static [u8]
).
Arguments are not "byte-stringified".
Example
ⓘThis code runs with edition 2018
use ::byte_strings::concat_bytes; let bytes = concat_bytes!(b"Hello, ", b"World!"); assert_eq!(bytes, b"Hello, World!");
Macro expansion:
For those curious, concat_bytes!(b"Hello, ", b"World!")
expands to:
{ const __byte_strings__concat_bytes: &'static [u8; 13usize] = b"Hello, World!"; __byte_strings__concat_bytes }
This trick is needed to circumvent the current restriction of procedural macros being able to expand to items only.