#concatenation #const #byte #string

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

#847 in Rust patterns

Download history 810/week @ 2025-01-28 576/week @ 2025-02-04 113/week @ 2025-02-11 96/week @ 2025-02-18 531/week @ 2025-02-25 170/week @ 2025-03-04 462/week @ 2025-03-11 312/week @ 2025-03-18 449/week @ 2025-03-25 156/week @ 2025-04-01 164/week @ 2025-04-08 245/week @ 2025-04-15 104/week @ 2025-04-22 145/week @ 2025-04-29 108/week @ 2025-05-06 132/week @ 2025-05-13

508 downloads per month
Used in 4 crates (2 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

OSZAR »