Rust

Rust

Made by DeepSource

Found const declaration of atomic type RS-W1076

Anti-pattern
Minor

Atomic types provide thread-safety, and are generally not expected to be constants. Using a Atomic type as a const value is redundant as non-mutable references to shared value are already thread-safe. Consider either changing const to static or dropping the use of Atomic.

If this is meant to be used as a default initial value, consider constructing them from non-atomic values, using the Atomic::new or by default type conversion for Integer types.

Bad practice

const GLOBAL_THREAD_COUNT: AtomicUsize = AtomicUsize::new(0);

Recommended

static GLOBAL_THREAD_COUNT: AtomicUsize = AtomicUsize::new(0);