Global variables in Rust
Apart from let
the keywords const
and static
can be used to create variables, and they are for values that don't change.
Rust also doesn't do type inference for them, you have to write their types.
They are written with CAPITAL LETTERS and usually outside the main function, so they are accessible everywhere in the program and are don't get dropped.
const NUMBER_OF_MONTHS: u32 = 12;
static SEASONS: [&str, 3] = ["RAINY", "HOT", "HARMATTAN"]