atomic_macro

Crates.ioatomic_macro
lib.rsatomic_macro
version0.1.1
sourcesrc
created_at2022-01-19 07:08:21.091296
updated_at2022-01-19 10:23:17.742773
descriptionAttribute macros for generating AtomicXXX
homepage
repositoryhttps://github.com/rise0chen/atomic_macro
max_upload_size
id516599
size16,377
Rise Chen (rise0chen)

documentation

https://docs.rs/atomic_macro

README

atomic_macro

Usage

#[atomic_macro::atomic(32)]
struct SomeStruct {
    field_one: u8,
    field_two: u16,
}
impl From<u32> for SomeStruct {
    fn from(value: u32) -> Self {
        ...
    }
}
impl From<SomeStruct> for u32 {
    fn from(value: SomeStruct) -> Self {
        ...
    }
}

Generates

enum AtomicSomeStruct(AtomicU32);
impl AtomicSomeStruct {
    fn load(&self, order: Ordering) -> SomeStruct;
    fn store(&self, val: SomeStruct, order: Ordering);
    ...
}
Commit count: 2

cargo fmt