Amanieu / atomic-rs

Generic Atomic<T> type for Rust
Apache License 2.0
218 stars 23 forks source link

Using non-zero integers with atomic 0.6 #39

Open nazar-pc opened 9 months ago

nazar-pc commented 9 months ago

What prevents me from upgrading to 0.6 right now is that bytemuck::Pod isn't implemented for NonZero* types. Is it expected or side-effect of the implementation?

Maybe a separate trait is needed that is auto-implemented for types that implement Pod, but can also be implemented for other types like NonZero*?

Amanieu commented 9 months ago

Maybe we could use NoUninit instead of Pod. Would you be willing to write up a PR for this?

nazar-pc commented 9 months ago

That sounds like a solution, I'll try to create a PR this weekend

CryZe commented 9 months ago

It already uses NoUninit: https://github.com/Amanieu/atomic-rs/blob/79ace14a69d8d4a45cc7f6cd06ff0cbb5849b2fd/src/lib.rs#L119

Amanieu commented 9 months ago

NonZero* types implement NoUninit: https://docs.rs/bytemuck/latest/bytemuck/trait.NoUninit.html