小弧光的博客

公众号:小弧光黑板报

导航

atomic_enum rust 原子枚举类型

https://docs.rs/atomic_enum/latest/atomic_enum/

#[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);

 

posted on 2023-06-09 09:30  小弧光  阅读(12)  评论(0编辑  收藏  举报