Macro const_str::join

source ·
macro_rules! join {
    ($strs: expr, $sep: expr) => { ... };
}
Expand description

Concatenates string slices into a string slice, separated by a given separator.

§Examples

const WORDS: &[&str] = &["hello", "world"];
const MESSAGE1: &str = const_str::join!(WORDS, " ");
assert_eq!(MESSAGE1, "hello world");

const NUMS: &[&str] = &["1", "2", "3"];
const MESSAGE2: &str = const_str::join!(NUMS, ", ");
assert_eq!(MESSAGE2, "1, 2, 3");

const EMPTY: &[&str] = &[];
const MESSAGE3: &str = const_str::join!(EMPTY, ", ");
assert_eq!(MESSAGE3, "");