macro_rules! string_arr {
() => { ... };
($($x:expr),+ $(,)?) => { ... };
}
Expand description
Create an array
of [String; N]
with string literals
ยงExamples
Empty arrays:
use string_literals::string_arr;
let arr: [String; 0] = string_arr![];
assert!(arr.is_empty());
Non-empty arrays:
use string_literals::string_arr;
let old: [String; 2] = [String::from("Alice"), String::from("Bob")];
let new: [String; 2] = string_arr!["Alice", "Bob"];
assert_eq!(new.len(), 2);
assert_eq!(new[0], String::from("Alice"));
assert_eq!(new[1], String::from("Bob"));