Macro kvarn::prelude::utils::build_bytes

source ·
macro_rules! build_bytes {
    () => { ... };
    ($($bytes:expr),+ $(,)?) => { ... };
}
Expand description

Convenience macro to create a Bytes from multiple &[u8] sources.

Allocates only once; capacity is calculated before any allocation.

Works like the vec! macro, but takes byte slices and concatenates them together.

§Examples

let built_bytes = build_bytes!(b"GET", b" ", b"/foo-", b"bar", b" HTTP/2");
assert_eq!(built_bytes, Bytes::from_static(b"GET /foo-bar HTTP/2"));