Creating a static const Vec [duplicate]

Do you want it to be mutable? Do the values have to be Strings? If the answer is “no” to both, you can use an array of string slices ([&str; N]) instead of a Vec<String>:

const LEFT: [&'static str; 3] = ["Hello", "World", "!"];
// or
const LEFT: &'static [&'static str] = &["Hello", "World", "!"];

consts are basically copied wherever they are used, so the second form may be preferable depending on the size of the array.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)