Macro join
macro_rules! join {
($strs: expr, $sep: expr) => { ... };
}
Available on crate feature
dep_const_str
only.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, "");