#concatenation #const

no-std concat_const

const &[u8] and &str concatenation

4 releases

0.2.0 Apr 8, 2025
0.1.3 Oct 12, 2023
0.1.2 Oct 7, 2023
0.1.1 Oct 7, 2023
0.1.0 Oct 3, 2023

#1221 in Rust patterns

Download history 175/week @ 2025-08-15 60/week @ 2025-08-22 139/week @ 2025-08-29 69/week @ 2025-09-05 63/week @ 2025-09-12 46/week @ 2025-09-19 351/week @ 2025-09-26 372/week @ 2025-10-03 123/week @ 2025-10-10 193/week @ 2025-10-17 91/week @ 2025-10-24 170/week @ 2025-10-31 93/week @ 2025-11-07 42/week @ 2025-11-14 41/week @ 2025-11-21 123/week @ 2025-11-28

321 downloads per month
Used in 5 crates (3 directly)

MIT/Apache

6KB
116 lines

Rust const &[u8] and &str concatenation

Crate API

const NUM: i128 = 1;
// &str
const HELLO: &str = "Hello";
const RES: &str = concat_const::concat!(HELLO, "world", concat_const::int!(NUM));
assert_eq!(RES, "Helloworld1");
// bytes
const HELLO: &[u8] = b"Hello";
const RES: &[u8] = concat_const::concat_bytes!(HELLO, b"world", concat_const::int_bytes!(NUM));
assert_eq!(RES, b"Helloworld1");

Look at the tests for more usage examples

No runtime deps