atomic_enum icon indicating copy to clipboard operation
atomic_enum copied to clipboard

Dynamically choose underlying atomic unsigned size based on enum variants count

Open tqwewe opened this issue 6 months ago • 0 comments

This library uses AtomicUsize as the underlying numeric atomic size. In most cases, AtomicU8 would be possible, but it would be nice if the macro could change the underlying atomic type based on how many variants there are.

Of course, some embedded devices don't support atomic u8 or other types specifically, but this could be resolved by falling back to AtomicUsize using conditional compilation.

Eg:

#[cfg(target_has_atomic = "8")]
pub struct AtomicCatState(AtomicU8);

#[cfg(not(target_has_atomic = "8"))]
pub struct AtomicCatState(AtomicUsize);

tqwewe avatar Jul 14 '25 09:07 tqwewe