mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-14 01:11:01 +00:00
One macro to serialize all atomics
This commit is contained in:
+15
-40
@@ -844,48 +844,23 @@ where
|
|||||||
|
|
||||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||||
macro_rules! atomic_impl {
|
macro_rules! atomic_impl {
|
||||||
($ty:ident) => {
|
($($ty:ident)*) => {
|
||||||
impl Serialize for $ty {
|
$(
|
||||||
#[inline]
|
impl Serialize for $ty {
|
||||||
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
|
||||||
where
|
where
|
||||||
S: Serializer,
|
S: Serializer,
|
||||||
{
|
{
|
||||||
self.load(Ordering::SeqCst).serialize(serializer)
|
self.load(Ordering::SeqCst).serialize(serializer)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
)*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
#[cfg(all(feature = "std", std_integer_atomics))]
|
||||||
atomic_impl!(AtomicBool);
|
atomic_impl! {
|
||||||
|
AtomicBool
|
||||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
AtomicI8 AtomicI16 AtomicI32 AtomicI64 AtomicIsize
|
||||||
atomic_impl!(AtomicI8);
|
AtomicU8 AtomicU16 AtomicU32 AtomicU64 AtomicUsize
|
||||||
|
}
|
||||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
|
||||||
atomic_impl!(AtomicI16);
|
|
||||||
|
|
||||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
|
||||||
atomic_impl!(AtomicI32);
|
|
||||||
|
|
||||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
|
||||||
atomic_impl!(AtomicI64);
|
|
||||||
|
|
||||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
|
||||||
atomic_impl!(AtomicIsize);
|
|
||||||
|
|
||||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
|
||||||
atomic_impl!(AtomicU8);
|
|
||||||
|
|
||||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
|
||||||
atomic_impl!(AtomicU16);
|
|
||||||
|
|
||||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
|
||||||
atomic_impl!(AtomicU32);
|
|
||||||
|
|
||||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
|
||||||
atomic_impl!(AtomicU64);
|
|
||||||
|
|
||||||
#[cfg(all(feature = "std", std_integer_atomics))]
|
|
||||||
atomic_impl!(AtomicUsize);
|
|
||||||
|
|||||||
Reference in New Issue
Block a user