Is it possible to use global variables in Rust?
It’s possible, but heap allocation is not allowed directly. Heap allocation is performed at runtime. Here are a few examples: static SOME_INT: i32 = 5; static SOME_STR: &’static str = “A static string”; static SOME_STRUCT: MyStruct = MyStruct { number: 10, string: “Some string”, }; static mut db: Option<sqlite::Connection> = None; fn main() { println!(“{}”, … Read more