Crate atomic_enum

source ·
Expand description

An attribute to create an atomic wrapper around a C-style enum.

Internally, the generated wrapper uses an AtomicUsize to store the value. The atomic operations have the same semantics as the equivalent operations of AtomicUsize.


enum CatState {
    Dead = 0,

let state = AtomicCatState::new(CatState::Dead);, Ordering::Relaxed);

assert_eq!(state.load(Ordering::Relaxed), CatState::Alive);

This attribute does not use or generate any unsafe code.

The crate can be used in a #[no_std] environment.

Attribute Macros§

  • Creates an atomic wrapper around a C-style enum.