In C I would write a file-level static uint32_t counter; and update it from anywhere. In Rust, static mut COUNTER: u32 = 0; compiles, but every access needs an unsafe block and newer compilers complain about taking references to it. A plain static without mut cannot be assigned at all.
What is the idiomatic replacement for a global counter, and for a larger global object such as a configuration table that is filled in once at start-up? The counter version also has to work from an interrupt handler on a microcontroller.




