Rust Global Variable and Impl Singleton elegantly
· β 3 min read
Although the mechanism of Rust Lifetime suggest people using local variable guaranteed to ownership is correct, we inevitably need to use global variables in some situations. Rust designer have added many limitations to guarantee that global variables are safe in terms of memory and threading, compared to other languages such as C/C++ and Python. These limitations indeed help developers avoid lots of crash or unexpected issues that are difficult to