atomex

Crates.ioatomex
lib.rsatomex
version0.1.0
sourcesrc
created_at2024-10-09 09:23:20.82389
updated_at2024-10-09 09:23:20.82389
descriptionAtomics extensions in Rust
homepagehttps://github.com/ljsnogard/atomex-rs
repository
max_upload_size
id1402187
size44,927
lino (ljsnogard)

documentation

README

atomex

Some useful extensions around Atomic* in core::sync::atomic.

This crate is mainly inspired by atomic-traits

Example

use core::sync::atomic::*;
use atomex::AtomicCount;

let atm = AtomicUsize::new(0usize);
let cnt = AtomicCount::<usize, AtomicUsize>::new(atm);

let mut atm = cnt.into_inner();
let cnt = AtomicCount::<usize, &mut AtomicUsize>::new(&mut atm);

assert_eq!(cnt.inc(), 0usize);
assert_eq!(cnt.dec(), 1usize);
assert_eq!(cnt.val(), 0usize);
Commit count: 0

cargo fmt