macro_rules! from_iter { ($($rem:tt)*) => { ... }; }
Expand description
Makes a &'static str
from an const iterator over &str
s or char
s
§Example
§Iterator over strings
use konst::string;
const S: &str = string::from_iter!(
&["foo", "bar", "baz"],
flat_map(|s| {
// By value iteration over arrays isn't supported,
// but by-reference iteration is supported
&[*s, ", "]
})
);
assert_eq!(S, "foo, bar, baz, ");
§Iterator over chars
use konst::{iter, string};
const S: &str = string::from_iter!('a'..='z');
assert_eq!(S, "abcdefghijklmnopqrstuvwxyz");