5 releases
0.2.1 | Mar 3, 2024 |
---|---|
0.2.0 | Nov 14, 2023 |
0.1.2 | Oct 18, 2023 |
0.1.1 | Oct 18, 2023 |
0.1.0 | Oct 18, 2023 |
#71 in #enum
15,042 downloads per month
Used in 3 crates
(via portable_atomic_enum)
16KB
248 lines
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
.
Example
#[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.
Dependencies
~245–700KB
~17K SLoC