macro_rules! as_bytes {
    (
    $($expr:expr),* $(,)?
) => { ... };
}
Expand description

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

Example

use ::byte_strings::concat_bytes;

let bytes = concat_bytes!(b"Hello, ", b"World!");
assert_eq!(bytes, b"Hello, World!");

Macro expansion:

concat_bytes!(b"Hello, ", b"World!") expands to b"Hello, World!"