exhaust/impls/
core_sync.rs

1#![cfg_attr(not(target_has_atomic = "8"), allow(unused_imports, unused_macros))]
2
3macro_rules! impl_atomic {
4    ($t:ty, $atomic:ident) => {
5        impl Exhaust for atomic::$atomic {
6            $crate::patterns::delegate_factory_and_iter!($t);
7
8            fn from_factory(factory: Self::Factory) -> Self {
9                atomic::$atomic::new(factory)
10            }
11        }
12    };
13}
14use impl_atomic;
15
16#[rustfmt::skip]
17mod atomic_impl {
18    use core::sync::atomic;
19    use crate::Exhaust;
20    use super::impl_atomic;
21
22    #[cfg(target_has_atomic = "8")]  impl_atomic!(bool, AtomicBool);
23    #[cfg(target_has_atomic = "8")]  impl_atomic!(i8, AtomicI8);
24    #[cfg(target_has_atomic = "8")]  impl_atomic!(u8, AtomicU8);
25    #[cfg(target_has_atomic = "16")] impl_atomic!(i16, AtomicI16);
26    #[cfg(target_has_atomic = "16")] impl_atomic!(u16, AtomicU16);
27    #[cfg(target_has_atomic = "32")] impl_atomic!(i32, AtomicI32);
28    #[cfg(target_has_atomic = "32")] impl_atomic!(u32, AtomicU32);
29
30    // * No `AtomicUsize` on the principle that it might be too large.
31    // * No `AtomicPtr` on the principle that we don't produce nonsense pointers.
32    // * No `Ordering` because it is `#[non_exhaustive]`.
33}