The function internally modifies/reads a global static mut, so as the docs correctly point out, it is UB to call this in a race with anything that uses it.
But the function then needs to be marked as unsafe.
Or, probably better yet, I'd use the crates lazy_static or once_cell (The functionality of once_cell is being added to the standard library, but is currently unstable) to lazily init as needed on function calls.
The function internally modifies/reads a global
static mut
, so as the docs correctly point out, it is UB to call this in a race with anything that uses it.But the function then needs to be marked as
unsafe
.Or, probably better yet, I'd use the crates lazy_static or once_cell (The functionality of once_cell is being added to the standard library, but is currently unstable) to lazily init as needed on function calls.