What is wrong with this code?
use std::sync::atomic::AtomicUsize;
static mut counter: AtomicUsize = AtomicUsize::new(0);
fn main() {}
I get this error:
error: const fns are an unstable feature
--> src/main.rs:3:35
|>
3 |> static mut counter: AtomicUsize = AtomicUsize::new(0);
|> ^^^^^^^^^^^^^^^^^^^
help: in Nightly builds, add `#![feature(const_fn)]` to the crate attributes to enable
The docs mention that other atomic int sizes are unstable, but AtomicUsize
is apparently stable.
The purpose of this is to get an atomic per-process counter.