An attribute to create an atomic wrapper around a C-style enum
Rust
51
14 commits
updated Jun 21, 2024
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.
# use atomic_enum::atomic_enum;
# use std::sync::atomic::Ordering;
#[atomic_enum]
#[derive(PartialEq)]
enum CatState {
Dead = 0,
BothDeadAndAlive,
Alive,
}
let state = AtomicCatState::new(CatState::Dead);
state.store(CatState::Alive, 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.
This crate is passively maintained.
137 followers · starred Nov 2021
229 followers · starred May 2021
13 followers · starred Mar 2021
70 followers · starred Mar 2022
An attribute to create an atomic wrapper around a C-style enum
Rust
51
14 commits
updated Jun 21, 2024
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.
# use atomic_enum::atomic_enum;
# use std::sync::atomic::Ordering;
#[atomic_enum]
#[derive(PartialEq)]
enum CatState {
Dead = 0,
BothDeadAndAlive,
Alive,
}
let state = AtomicCatState::new(CatState::Dead);
state.store(CatState::Alive, 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.
This crate is passively maintained.
137 followers · starred Nov 2021
229 followers · starred May 2021
13 followers · starred Mar 2021
70 followers · starred Mar 2022