Avatar ·

How to declare a constant array in global scope in Rust?

Hi everyone! I started learning Rust and encountered a problem that seems very strange to me. I'm trying to declare an array in global scope so it's accessible from different functions, but the compiler gives an error. Here's what I'm trying to do: ```rust const DAYS: [&str; 7] = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]; ``` But the compiler says something about "constant expression depends on a generic parameter" or "evaluation of constant value failed". Although in other languages (C, Java) this works without issues. I also tried: ```rust static DAYS: [&str; 7] = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]; ``` Then the compiler complains: "static items cannot have a non-Sync type". Please advise how to correctly declare a constant array of strings in global scope.