constcat
std::concat!
with support for const
variables and expressions.
Works on stable Rust ✨.
🚀 Getting started
Add constcat
to your Cargo manifest.
Import the macro using the following.
use concat;
🤸 Usage
String slices
concat!
works exactly like std::concat!
, concatenating &str
literals into a static string slice, except you can now pass variables and
constant expressions.
const CRATE_NAME: &str = env!;
const CRATE_VERSION: &str = env!;
const
const VERSION: &str = concat!;
Byte slices
concat_bytes!
works similarly to concat!
, concatenating const
&[u8]
expressions and literals into a static byte slice.
const VERSION: u32 = 1;
const
const HEADER: & = concat_bytes!;
T
slices
concat_slices!
is the underlying macro used for both of the above, this
can be used to concatenate const
&[T]
expressions into a static
slice.
This macro requires the type of slice to be specified in the form [T]:
before the comma separated expressions.
const MAGIC: & = &;
const VERSION: i32 = 1;
const HEADER: & = concat_slices!;
const PRIMARIES: &'static = &;
const SECONDARIES: &'static = &;
const COLORS: & = concat_slices!;
MSRV
This crate supports Rust 1.66 and above.
License
This project is distributed under the terms of both the MIT license and the Apache License (Version 2.0).
See LICENSE-APACHE and LICENSE-MIT for details.