atomic_enum_2021

Crates.ioatomic_enum_2021
lib.rsatomic_enum_2021
version0.1.0
sourcesrc
created_at2022-07-25 08:27:13.268672
updated_at2022-07-25 08:27:13.268672
descriptionAn attribute to create an atomic wrapper around a C-style enum, forked for Rust 2021
homepage
repositoryhttps://github.com/l1npengtul/atomic_enum_2021
max_upload_size
id632438
size18,122
lain ping tool (l1npengtul)

documentation

README

cargo version docs.rs version

atomic_enum_2021

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.

Forked and maintained by l1npengtul to remove warnings when compiling for modern versions of Rust.

Example

# 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.

MSRV

Rust 2021 Edition (1.56)

Commit count: 12

cargo fmt